An ultrasonic water-level sensor reads how full a tank is from above, without ever touching the water. Mounted at the top of a tank pointing down, it bounces a sound pulse off the surface and times the echo, and from that distance you get the level. Because nothing goes in the water, it does not foul or corrode, which makes it the everyday choice for nutrient reservoirs, rain barrels, and any tank where a sensor sitting in the liquid would not last.
What it is.
A small board with two ultrasonic transducers, one to send and one to listen, that connects to a microcontroller on a couple of pins. The cheap, familiar one is the HC-SR04; the version that matters for water is the JSN-SR04T, which puts the transducer in a sealed, waterproof probe on a cable so it survives a damp tank. Either way the board itself is inexpensive, and a small library does the timing.
How it reads a level.
The microcontroller pulses the trigger pin, the sensor sends a chirp of sound, and it reports back on the echo pin how long the sound took to return. Sound travels at a known speed, so that time becomes a distance: the gap from the sensor down to the water surface. Subtract that gap from the tank’s height and you have the water level. Measure the distance when the tank is empty and again when it is full, and you can map any reading to a level or even a volume.
HC-SR04 vs JSN-SR04T.
This is the buy-it-right choice for water. The HC-SR04 is the dollar sensor everyone starts with, but its open transducers are not waterproof, so condensation and splashes kill it in a real tank; keep it for dry-bench learning. The JSN-SR04T uses the same idea but moves the transducer into a sealed probe on a lead, so it tolerates the damp, humid air above a water surface. For any tank you actually deploy on, use the waterproof JSN-SR04T.
Mounting and gotchas.
A few things decide whether it reads cleanly. Mount it at the top, pointing straight down at the surface, above the highest water line. Ultrasonic dislikes a foamy or turbulent surface, which scatters the echo, and a narrow or stepped tank, whose walls throw back false returns; a calm, open surface reads best. There is a dead zone of roughly the first 20 centimeters where it cannot measure, so leave headroom. And because the speed of sound shifts with temperature, a cheap sensor drifts a little across a hot day, which is fine for a tank gauge but not for precision work.
Key facts.
Where it fits, and where it doesn’t.
Where it fits
- Nutrient reservoirs and dirty water, with nothing to foul.
- Rain barrels, cisterns, and irrigation tanks.
- A continuous level reading for a dashboard.
- Outdoor tanks, with the waterproof JSN-SR04T.
Where it doesn’t
- Foamy or turbulent surfaces, which scatter the echo.
- Narrow or stepped tanks, which throw false returns.
- The top ~20 cm dead zone; leave headroom.
- A bare HC-SR04 in a damp tank; it is not waterproof.
Resources & where to buy.
Adafruit HC-SR04 eTape (a contact gauge) Water level overview The Software Library
Frequently asked questions.
How does an ultrasonic water-level sensor work?
Mounted at the top of a tank pointing down, it sends a pulse of sound and times the echo off the water surface. Sound travels at a known speed, so that time becomes the distance from the sensor to the water. Subtract it from the tank height and you have the level. It never touches the water, which is its main advantage.
Should I use an HC-SR04 or a JSN-SR04T?
For a real tank, the JSN-SR04T. The HC-SR04 is the cheap one everyone learns on, but its open transducers are not waterproof, so condensation and splashes kill it in a damp tank. The JSN-SR04T moves the transducer into a sealed probe on a cable, so it survives the humid air above a water surface. Keep the HC-SR04 for dry-bench testing.
Why is my ultrasonic level reading jumpy?
Usually the surface or the mounting. Foam and turbulence scatter the echo, and a narrow or stepped tank throws back false returns from the walls. Mount it at the top pointing straight down at a calm, open part of the surface, keep it above the roughly 8-inch (20-centimeter) dead zone, and average a few readings. A calm tank reads steadily.
How do I turn the distance into a tank level?
Calibrate with two points. Measure the distance the sensor reports when the tank is empty and again when it is full, then map any reading in between to a level, or to a volume if you know the tank’s shape. A few lines on the microcontroller convert the raw distance into a percent-full or a depth you can chart and alert on.