Automatic Water Tank Controller with LM358, 555 & ULN2003

Build an automatic overhead water tank controller with LM358, 555, ULN2003 and 7805. No microcontroller or code: probe wiring, pump latch, overflow alarm and diagram.

  • DifficultyAdvanced
  • Build time5–8 hours
  • Board / MCUNo MCU: LM358 + NE555
  • Parts16 items
  • CodeNot needed

Need it ready-made? Buy Ready Project

This automatic water tank controller fills an overhead tank and switches the pump off when the water reaches the high probe. It is built from four everyday non-programmable ICs — a 7805 regulator, an LM358 dual op-amp, a NE555 timer and a ULN2003A Darlington array — so there is no microcontroller and no code to upload. Two transistors form a set-reset latch: the pump starts when the tank falls below the low probe and keeps running until the high probe gets wet. A fourth overflow probe enables the 555, which sounds a buzzer if the tank ever overfills.

Build and test it with a 12 V DC water pump (an aquarium or diaphragm pump is ideal). That keeps the whole project on low voltage. If you later switch a 230 V mains pump, use a properly rated enclosed relay or contactor and have the mains wiring done by a qualified person. Never put mains voltages on a breadboard.

Below you get a clear description of how the latch and alarm work, the full parts list, a pin-to-pin wiring table, and a connection diagram. Because every chip here is analog or a simple logic array, this project has no sketch to copy.

How the Water Tank Controller Works

A 12 V DC adapter powers the pump relay and the ULN2003 clamp pin. The same 12 V goes into a 7805, which makes a clean 5 V rail for the LM358 and the 555. Put a 10 µF electrolytic and a 0.1 µF ceramic capacitor on both the regulator input and the output, close to the 7805 pins.

Four stainless steel probes hang in the tank. The COM probe sits at the bottom and is wired to +5 V. The LOW, HIGH and OVERFLOW probes sit at about 20 percent, 90 percent and just above the high mark. Each sense probe has a 100 kΩ resistor to ground. When water touches a probe, it conducts from COM and the probe voltage rises well above the 2.5 V reference (two 10 kΩ resistors between +5 V and ground).

Inside the LM358, op-amp A compares the HIGH probe (pin 3) with 2.5 V (pin 2). Pin 1 goes high when the tank is full. Op-amp B compares the LOW probe (pin 5) with 2.5 V (pin 6). Pin 7 goes high when water is at or above the low probe.

The pump must not chatter every time the water ripples around one probe. That is what the latch is for:

  • Start: when the tank is below LOW, pin 7 is low. Transistor Q1 inverts that signal, so START is high. Diode D1 pulls the RUN node high and the pump turns on.
  • Hold: once the relay closes, its normally-open contact feeds 12 V into a 15 kΩ + 10 kΩ divider (about 4.8 V). Diode D2 keeps RUN high even after the water rises past the low probe and START falls.
  • Stop: when the tank reaches HIGH, pin 1 goes high and transistor Q2 shorts RUN to ground. The relay drops out, HOLD disappears, and the pump stays off until the water falls below LOW again.

The ULN2003A sinks the relay coil from IN1/OUT1, so the small RUN signal never has to carry coil current. Pin 9 (COM) goes to +12 V and uses the chip’s built-in clamp diodes. A green LED on IN3/OUT3 lights while the pump is on. A red LED driven from LM358 pin 1 (through another ULN2003 channel) lights when the tank is full.

The NE555 runs as a slow astable (about 0.7 Hz with 10 kΩ, 100 kΩ and 10 µF). Its RESET pin (pin 4) is held low by a 100 kΩ resistor, so the chip stays silent. When water reaches the overflow probe, that pin is pulled up through the water toward +5 V, the 555 starts, and pin 3 drives ULN2003 IN2. OUT2 then beeps the buzzer. If the high-level shutoff is working, you should never hear this alarm — it is the safety net.

Components Required

  • 7805 voltage regulator – 1
  • LM358 dual op-amp – 1
  • NE555 timer – 1
  • ULN2003A Darlington transistor array – 1
  • 12 V SPDT relay (coil 12 V; contacts rated for your pump) – 1
  • 12 V DC water pump – 1 (for safe testing)
  • 12 V DC adapter, 1 A or more – 1
  • Active buzzer, 5 V or 12 V – 1
  • BC547 or 2N2222 NPN transistors – 2
  • 1N4148 diodes – 2
  • Stainless steel probes or bolts with insulated wire – 4
  • Resistors: 10 kΩ × 6, 100 kΩ × 4, 15 kΩ × 1, 330 Ω × 2
  • Capacitors: 10 µF / 25 V electrolytic × 2, 10 µF / 16 V electrolytic × 1, 0.1 µF ceramic × 2, 10 nF ceramic × 1
  • LEDs: green (pump on) and red (tank full) – 1 each
  • 8-pin IC sockets (optional) – 2, and one 16-pin socket for the ULN2003
  • Breadboard or perfboard, jumper wires, and a small heatsink for the 7805 if it runs warm

Wiring Table (Pin-to-Pin)

PartPin / NodeConnects ToNotes
7805IN (pin 1)+12 V adapter +10 µF and 0.1 µF from IN to GND, close to the regulator
7805GND (pin 2)Circuit GNDJoin to the adapter −
7805OUT (pin 3)+5 V rail10 µF and 0.1 µF from OUT to GND
LM358VCC (pin 8)+5 VDo not run the op-amp from 12 V in this build
LM358GND (pin 4)GNDCommon ground
Reference dividerMidpoint of two 10 kΩ resistorsLM358 pins 2 and 6Top 10 kΩ to +5 V, bottom 10 kΩ to GND (about 2.5 V)
Probe COMBottom of the tank+5 VLowest stainless rod; stays in water whenever the tank is not empty
Probe LOWAbout 20% heightLM358 pin 5100 kΩ from pin 5 to GND
Probe HIGHAbout 90% heightLM358 pin 3100 kΩ from pin 3 to GND
Probe OVERFLOWA few centimetres above HIGHNE555 RESET (pin 4)100 kΩ from pin 4 to GND
LM358Pin 7 (low-level output)Q1 base through 10 kΩHigh when water is at or above LOW
Q1 (BC547)EmitterGNDInverts pin 7 to make START
Q1 (BC547)Collector (START)RUN node through D1 (1N4148)Also a 10 kΩ pull-up from the collector to +5 V
LM358Pin 1 (high-level output)Q2 base through 10 kΩHigh when the tank is full
Q2 (BC547)EmitterGNDReset transistor
Q2 (BC547)CollectorRUN nodeShorts RUN to ground when the tank is full
RelayNO contactHOLD divider, then D2 to RUN15 kΩ from NO to the midpoint, 10 kΩ from the midpoint to GND, then D2 (1N4148) to RUN
RUN node—ULN2003 IN1 (pin 1) and IN3 (pin 3)High means the pump should run
ULN2003AGND (pin 8)GNDCommon ground
ULN2003ACOM (pin 9)+12 VClamp diodes for the relay coil
ULN2003AOUT1 (pin 16)Relay coil −Relay coil + goes to +12 V
RelayCOM+12 VSwitched pump supply
RelayNO12 V pump + and the HOLD dividerPump − goes to GND
NE555VCC (pin 8)+5 V
NE555GND (pin 1)GND
NE555TR (pin 2) and TH (pin 6)Tied togetherAstable mode
NE555DIS (pin 7)10 kΩ to +5 V and 100 kΩ to pins 2 and 6Timing resistors
Timing capacitor10 µFPins 2 and 6 to GNDGives a beep of about 0.7 Hz
NE555CTRL (pin 5)10 nF to GNDKeeps the control pin quiet
NE555OUT (pin 3)ULN2003 IN2 (pin 2)Alarm drive
ULN2003AOUT2 (pin 15)Buzzer −Buzzer + to +12 V, or to +5 V if you use a 5 V buzzer
Green LEDAnode through 330 Ω to +5 VCathode to ULN2003 OUT3 (pin 14)IN3 is tied to RUN
Red LEDAnode through 330 Ω to +5 VCathode to ULN2003 OUT4 (pin 13)IN4 (pin 4) is tied to LM358 pin 1

Use one common ground for the adapter, the 7805, both 8-pin ICs, the ULN2003, the two transistors and the pump. If your buzzer is a 5 V type, take its positive lead to +5 V instead of +12 V so you do not burn it out.

Connection Diagram

The overview image shows the main blocks. Use the labelled diagram that follows, and the wiring table, for the exact pin connections.

Connection diagram of an automatic water tank controller using LM358, NE555, ULN2003 and 7805 ICs with tank probes, pump relay and overflow buzzer
Automatic water tank controller wiring diagram with LM358, 555, ULN2003 and 7805 Four tank probes to LM358 and 555, a transistor latch driving ULN2003 IN1 and a pump relay, and a 555 overflow alarm driving a buzzer through ULN2003 IN2. Power comes from 12 V through a 7805 regulator. Automatic Water Tank Controller: Connection Diagram LM358 level sensors + transistor latch + ULN2003 pump drive + NE555 overflow alarm (no microcontroller) 7805 regulator IN = +12 V (adapter +) GND = adapter – / circuit GND OUT = +5 V rail +12 V rail +5 V rail (add 10 µF and 0.1 µF on IN and OUT) Overhead tank OVERFLOW HIGH LOW COM (+5 V) Stainless probes LM358 dual op-amp 8 VCC = +5 V 3 HIGH probe (100k to GND) 2 2.5 V reference 1 OUT = tank full 5 LOW probe (100k to GND) 6 2.5 V reference 7 OUT = water at/above LOW 4 GND 2.5 V from two 10 kΩ resistors (+5 V to GND) Latch (set / reset) Q1 BC547 inverter Base: pin 7 via 10 kΩ Collector: START (10 kΩ to +5 V) Q2 BC547 reset Base: pin 1 via 10 kΩ RUN node D1 from START, D2 from HOLD pin 1 pin 7 ULN2003A IN1 (pin 1) = RUN OUT1 (pin 16) = relay coil – IN2 (pin 2) = 555 pin 3 OUT2 (pin 15) = buzzer – COM (pin 9) = +12 V GND (pin 8) = GND IN3 = RUN, OUT3 = green LED – RUN 12 V SPDT relay Coil + = +12 V Coil – = ULN OUT1 COM = +12 V NO = pump + and HOLD 12 V DC pump + from relay NO, – to GND HOLD: relay NO through 15 kΩ + 10 kΩ divider, then D2 to RUN NE555 overflow alarm (astable) 8 VCC = +5 V 1 GND 4 RESET = OVERFLOW probe 2 and 6 tied, 10 µF to GND 7 10 kΩ to +5 V, 100 kΩ to pins 2 and 6 5 10 nF to GND 3 OUT to ULN2003 IN2 555 pin 3 overflow wire from tank Active buzzer + to +12 V (or +5 V if 5 V type) – to ULN2003 OUT2 Indicators Green LED: pump ON (330 Ω to +5 V, cathode OUT3) Red LED: tank full (LM358 pin 1 to ULN IN4) Follow the wiring table for every resistor and diode. Common GND for the adapter, 7805, ICs, transistors, ULN2003 and pump.
Connection diagram for the LM358, 555 and ULN2003 water tank controller. Match each labelled pin to the wiring table above.

How to Build and Set the Probes

  1. Wire the 7805 first and confirm you have a steady 5 V rail before you insert the other ICs.
  2. Add the 2.5 V reference divider and check that LM358 pins 2 and 6 sit near 2.5 V.
  3. Fit the LM358, the two transistors, the two diodes and the ULN2003, then the relay and the green LED. Leave the 555 and buzzer until the pump latch works.
  4. Hang the four probes so they cannot swing into each other. COM must be the lowest. Space LOW, HIGH and OVERFLOW to match your tank.
  5. For a first test, stand the four probes in a plastic jar or bucket instead of the real overhead tank. Use a 12 V DC pump that recirculates water back into the same jar, or simply watch the relay and the green LED.
  6. If tap water is very pure and a probe does not switch the comparator, raise the pull-down resistors from 100 kΩ to 470 kΩ, or move that pair of probes closer together. Do not add salt to a drinking-water tank.
  7. When the latch works, add the 555, the overflow probe resistor and the buzzer. Raise the water to the overflow probe on purpose once, confirm the alarm, then lower the probe so normal fill-and-stop never reaches it.

Testing the Controller

  1. Start with the jar below the LOW probe. The green LED should light and the relay should click on. The 12 V pump (if connected) should run.
  2. Raise the water past LOW but not as far as HIGH. The pump must stay on. That proves the HOLD path through the relay contact and D2.
  3. Raise the water to HIGH. The red LED should light, the relay should drop out and the pump should stop.
  4. Lower the water so HIGH goes dry but LOW is still wet. The pump must stay off. That is the other half of the latch.
  5. Lower the water below LOW. The pump should start again.
  6. Raise the water to the overflow probe. The buzzer should beep on and off about once a second. Drop the water below that probe and the alarm should stop.

Troubleshooting

ProblemFix
7805 gets very hotThe relay coil or a wiring short is drawing too much from the 5 V rail. The coil must run from +12 V through the ULN2003, not from 5 V. Add a heatsink and check for solder bridges.
Pump never startsCheck RUN with a meter. If it never goes high, look at Q1, the 10 kΩ collector pull-up and D1. Confirm COM is on +5 V and the LOW probe really reaches pin 5.
Pump never stopsConfirm the HIGH probe reaches LM358 pin 3 and that Q2 can pull RUN to ground (about 0 V) when you touch the HIGH probe to COM. Check that pin 1 goes high when HIGH is wet.
Pump chatters on and off near one probeThe latch is not holding. Check D2, the 15 kΩ + 10 kΩ divider on the relay NO contact, and that the relay COM is really at +12 V when the coil is energised.
A probe does nothingClean the metal, shorten the gap to COM, or raise that probe’s 100 kΩ pull-down to 470 kΩ. Very long thin wires pick up noise — keep probe cables reasonably short.
Buzzer stays silent at overflowRESET (pin 4) must rise well above 0.7 V. Check the overflow pull-down and the ULN2003 IN2/OUT2 path. A passive buzzer (no internal oscillator) will only click — use an active buzzer.
Buzzer runs all the timePin 4 is not pulled down, or the overflow probe is touching COM or sitting in water. Confirm the 100 kΩ from pin 4 to GND.

Ideas to Extend This Project

  • Add a sump or underground-tank dry-run probe with a second LM358 so the pump cannot run if the source is empty.
  • Wire a second relay channel on the ULN2003 to switch a solenoid valve instead of, or as well as, a pump.
  • Bring LOW, HIGH and OVERFLOW status to three extra LEDs so you can see each probe without dipping a meter in the tank.
  • Replace the two 10 kΩ reference resistors with a 10 kΩ preset if you want to tune the trip point for very pure or very hard water.

FAQ

Why is there no code? The 7805, LM358, NE555 and ULN2003 are analog and logic chips, not microcontrollers. The behaviour is set by the wiring, the probe heights and a few resistors.

Can I use this on a 230 V borewell or overhead-tank pump? The control side stays at 12 V and 5 V. Only a properly rated enclosed relay or contactor should switch a mains pump, and a qualified person should do that wiring. For learning and for the tests in this article, use a 12 V DC pump.

Will the probes rust? Use stainless steel rods or bolts. Ordinary iron or copper will corrode in water and give false readings. Keep the wiring joints above the water line.

Can I power the LM358 from 12 V instead of 5 V? The LM358 can run from 12 V, but then the probe pull-ups, the 2.5 V divider and the 555 supply would no longer match. Keep the op-amp and the 555 on the 7805’s 5 V rail as drawn.

What pump current can the ULN2003 handle? The ULN2003 drives the relay coil, not the pump motor. A typical 12 V relay coil is 30 to 80 mA, which is well inside one ULN2003 channel (500 mA). Size the relay contacts for the pump’s own current.

Related Projects

Browse more Industrial Automation on Arduino Project Hub.

1 thought on “Automatic Water Tank Controller with LM358, 555 & ULN2003”

Leave a Comment