This repo shows, how to build a liquid level switch by using an IR level sensor.
An IR liquid level sensor works similar to an IR light barrier, with a transparent plastic hood. When the sensor comes into contact with liquid, the refraction at the interface changes, and with it the strength of the reflected IR beam. It can detect almost any liquid type, oil or water based, and is suitable for harsh environments. The advantage of this sensor is the high accuracy, usually ±1mm, and the robustness, and of course the low price. The disadvantage is that it can only measure at one point, but not continuously.
The here described circuit can be used in many situations, e.g. for level measurement or as a leak detector. The circuit of the level switch is quite simple. The output signal at pin2 of the sensor (P3) is amplified by transistor Q1. The transistor Q1 is turned on, as soon as the output goes from LOW to HIGH, and the relay toggles. It is supplied with 5V DC at P2.
Schematic
Purchase link: https://www.ebay.de/itm/133996718815