Build a Water Tank Level Monitor with Arduino Uno and an Ultrasonic Sensor
Share
A DIY water tank level monitor works by pointing an ultrasonic sensor straight down into the tank from a fixed mount at the top: the sensor fires a short burst of sound above human hearing and times how long the echo takes to bounce back off the water surface, and a microcontroller converts that time-of-flight reading into a distance, compares it against the levels you set for "full" and "low," and switches on a buzzer or LED the moment the water crosses one of those thresholds. Because the sensor never touches the water, there is nothing to corrode or foul over time, which is why this approach is common for the overhead and sump tanks found on Indian rooftops and in underground sumps.
What parts does a water tank level monitor need?
At minimum, the build needs four things: a microcontroller to run the logic, an ultrasonic distance sensor to read the water level, a buzzer or LED to raise the alert, and a breadboard with jumper wires to connect everything before you commit to a permanent enclosure. An Arduino Uno is a common choice for this project because it has enough digital I/O to drive an HC-SR04 sensor's trigger and echo pins and a buzzer pin with no extra components, and it can run entirely off a USB power adapter rather than needing batteries changed on a rooftop.
How does an ultrasonic sensor measure water level from above?
An HC-SR04 module has two visible "eyes": one sends out a 40kHz ultrasonic pulse when the Arduino pulses its trigger pin, and the other listens for that pulse to bounce back off the water surface and return to the echo pin. The Arduino measures the time between sending and receiving in microseconds, and because sound travels at a known speed through air, that time converts directly to a distance — typically accurate from about 2cm to 400cm away, according to the module's spec. Subtract that distance from the known height of an empty tank and you get the current water level; compare that level against a low and a full threshold in code, and you know when to sound the alert.
How do you mount the sensor without it getting wet?
The sensor sits above the water, not in it, which is the point of choosing ultrasonic over a conductive probe — but it still needs to be shielded from splashes, condensation, and monsoon humidity. In practice that means fixing the HC-SR04 face-down through a hole in the tank lid or in a small enclosure bolted to the lid, with the trigger and echo wires running down to the Arduino outside the tank in a sealed or gasketed cable gland, and keeping the sensor's face perpendicular to a still patch of water rather than aimed at the inlet pipe or a float valve, both of which cause false echoes.
Can this monitor a buried/underground tank too?
Yes — the electronics don't change, only the access point. For an underground sump, the HC-SR04 is mounted at the top of the access chamber or inspection cover instead of a rooftop tank lid, aimed straight down at the water, with the signal wires run up through the same opening you use to inspect or refill the sump. The main practical difference is cable length: longer runs between the sensor and the Arduino are more prone to electrical noise, so keeping the wiring short and using a shielded or twisted-pair cable for longer drops makes the readings more reliable.
Watch it built live
We asked Compoden's storefront assistant this exact prompt: "I want to build a water tank level monitor with an alert using an Arduino Uno and an ultrasonic sensor." It returned a complete six-part tray in one pass — no follow-up needed — matching a microcontroller, water level sensor, alert indicator, prototyping board, wiring, and power supply against in-stock catalog items.
Here is what the assistant said about the build, quoted directly from its reply:
"This build creates a system to monitor the water level in a tank and alert you when it reaches a certain point. An ultrasonic sensor measures the distance to the water, and a small computer board processes this information. If the water level is too low or too high, a buzzer will sound to let you know."
On why it picked the HC-SR04 specifically: "This sensor is chosen because it directly provides the distance measurement needed for your water level monitor." And on the one real installation risk it flagged unprompted: "the ultrasonic sensor needs a clear path to the water; anything blocking the sound waves will give inaccurate readings."
Watch the firmware get generated
Separately, we gave Compoden's Soldr firmware assistant this prompt: "I'm building a water tank level monitor with an Arduino Uno, an ultrasonic sensor, and a buzzer. Write the full firmware to measure water level and sound the buzzer when the tank is low, printing status to the serial monitor." Soldr matched the same six parts from a fresh catalog check, then generated firmware in one pass — the code appeared complete in the editor rather than streaming in visibly.
The generated source defines TRIG_PIN 2 and ECHO_PIN 3 for the HC-SR04 and BUZZER_PIN 4 for the alert buzzer, with a comment block noting the tank dimensions and low-level threshold are meant to be adjusted for your own tank. Soldr's own summary of the file: "Here's the firmware for your Arduino Uno to monitor water level using the HC-SR04 ultrasonic sensor and sound a buzzer when the level is low. It prints the distance and calculated water level to the serial monitor, and activates the buzzer if the water level falls below a defined threshold." A serial monitor panel and a wiring tab are generated alongside the code so the pin assignments in the firmware match the physical connections.
Who this build is for
This is a first or second Arduino project: every part connects with jumper wires on a breadboard, no soldering is required, and the logic is a single distance comparison rather than anything involving multiple sensors or wireless communication. It suits anyone who wants a working rooftop tank or sump alert without buying a sealed commercial float-switch unit, and it's a reasonable weekend build for a student or hobbyist who has never wired an Arduino before but is comfortable following a pin diagram.
Get everything in this build
| Part | Role | Price | Add to cart |
|---|---|---|---|
| Arduino Uno R3 CH340G ATmega328P Board | Microcontroller | Rs.230 | Add to cart |
| HC-SR04 Ultrasonic Sensor | Water level sensor | Rs.85 | Add to cart |
| Active Piezo Buzzer Module 5V 2.3kHz | Alert indicator | Rs.45 | Add to cart |
| 400-Point Solderless Breadboard | Prototyping | Rs.40 | Add to cart |
| Male-to-Male Breadboard Jumper Wires (20cm, 24 AWG) | Wiring | Rs.40 | Add to cart |
| 5V 2A Micro-USB Power Adapter | Power supply | Rs.140 | Add to cart |
| Total (6 parts) | Rs.580 | Add all 6 to cart |
All six parts were confirmed in stock at the time this build was captured; check current availability and pricing on each product page before ordering.
Built and backed by Compoden: every part above ships from the same in-stock catalog that Compoden's AI assistant checks in real time before recommending anything, and the wiring and firmware shown here are generated from that exact same parts tray in Soldr, so what you buy is what the code and wiring diagram were written for.
FAQ
Do I need to calibrate the ultrasonic sensor for my specific tank? Yes. The firmware needs the tank's empty height and your chosen low/full thresholds entered as constants, since the sensor only measures distance to the water — it doesn't know your tank's dimensions on its own.
Can I add a second alert, like an LED in addition to the buzzer? Yes, an LED with a current-limiting resistor can be wired to any free digital pin on the Arduino Uno and triggered alongside the buzzer in the same threshold check.
Will the ultrasonic sensor work through a closed metal tank lid? No — ultrasonic sensors need line of sight through air to the water surface, so the sensor has to be mounted where it faces the water directly, typically through a hole or an open vent in the lid, not through solid metal or plastic.
What happens if the sensor loses power or the wiring fails? The buzzer will not sound in that case, since the alert logic depends on the Arduino running; for a rooftop or sump installation, periodically checking the wiring and power adapter is worth building into your routine.