This circuit lets you control a pump, to keep the level of water in a cellar below a certain threshold, for example. Power is supplied to the pump by a battery that is recharged automatically when the AC power line voltage is present.
If the water level rises, the electrodes touch the liquid and a current begins to flow. The transistor then conducts and the pump runs. The pump stops when the water level has dropped sufficiently for the electrodes to no longer be in contact with it — but not straight away, as the voltage on the transistor gate is maintained for a few seconds more by the 470 µF capacitors. This makes it possible to ensure the electrodes are completely clear of the water.
The battery is constantly tested by the comparator circuit around the TL071 IC. Its output drives the gate of the Triac in the transformer primary circuit via the optoisolator.
The transformer secondary charges the battery via the rectifier, using as little power as possible, and in this way keeps the battery at 13.2 V.
Note. Some component values may need modifying to suit operation on 115 VAC power.