Tired of babysitting a water pump? You can build an automatic rooftop tank controller over a weekend with parts most makers keep in a drawer. The shopping list is short: an ESP32 dev board, an ultrasonic distance sensor, a single 5V relay module, and a handful of jumper wires. Budget around PHP 500 if you pull the parts from the bins at circuit.rocks. A waterproof JSN-SR04T sensor is worth the small upgrade over a bare HC-SR04 when it has to sit above a humid tank.
The idea comes from [Jumpor], who got tired of a manual routine common in parts of India. Water arrives in an underground tank, then has to be pumped up to a rooftop tank before anyone can use it. The usual method is to flip the pump on and wait until water spills from an overflow pipe. That wastes water and time. The automated version watches the rooftop level and runs the pump only when it needs to, shutting off before anything spills over.
How the electronics work
The ultrasonic sensor sits in the tank cap and pings the water surface, reporting the distance back. An HC-SR04 reads from roughly 2 cm to 400 cm, plenty for a household tank. The ESP32 times the echo on a GPIO pin and converts the round trip into a level. When the water drops below a set point, the board pulls a GPIO pin high, the relay closes, and the lift pump kicks on. Once the sensor reads full, the ESP32 opens the relay and the pump stops. One gotcha the builder flagged: keep the surface outside the sensor’s 2 cm minimum window, or a too-close reading can misfire and trigger an overflow. Mind the 3.3V logic on the ESP32 side of the relay too.
Because the rig went into a rental, [Jumpor] made no permanent plumbing changes and fitted all the electronics into a spare tank cap, so the original can go back on later. That is a smart move for anyone in a dorm or shared house. Read the full build at Hackaday, then try adding a small OLED for a local readout or an MQTT feed so you can check the tank level from your phone.
Frequently Asked Questions
How does the controller know when to run the pump?
An ultrasonic sensor measures the distance to the water surface. When the level drops below a set point, the ESP32 closes a relay to start the lift pump, then stops it once the tank reads full.
What parts do I need to build it?
An ESP32 dev board, an ultrasonic sensor (a waterproof JSN-SR04T is ideal), a 5V relay module, jumper wires, and your existing pump. The bill of materials runs around PHP 500.
What will I learn if I build this?
You will practice reading a sensor over GPIO, converting echo timing into a real distance, and safely switching a pump through a relay. It is a compact intro to sensors, control logic, and IoT that maps straight onto thesis and capstone work.
