Ultrasound Tank Level Meter





Introduction: Ultrasound Tank Level Meter

Need to monitor the fluid level in a large diameter well, a tank, or an open container? This guide will show you how to make a sonar non-contact fluid level meter using cheap electronics!

The sketch above shows an overview of what we aimed for with this project. Our summer cottage has a large-diameter well to supply drinking water for use in the house. One day, my brother and I talked about how our grandfather used to measure the water level manually in order to keep track of the water consumption and influx throughout the summer to avoid overdraft. We thought that with modern electronics we should be able to revive the tradition, but with less manual labour involved. With a few programming tricks, we managed to use an Arduino with a sonar module to measure the distance down to the water surface (l) with reasonable reliability and an accuracy of ± a few millimetre. This meant that we could estimate the remaining volume V, using the known diameter D and depth L, with about ±1 litre accuracy.

Because the well is located about 25m from the house and we wanted the display indoors, we opted for using two Arduinos with a data link in between. You can easily modify the project to use just one Arduino if this is not the case for you. Why not use wireless data transfer? Partly due to simplicity and robustness (the wire is less likely to be damaged by moisture) and partly because we wanted to avoid using batteries on the sensor side. With a wire, we could route both data transfer and power through the same cable.

1) Arduino module in the house
This is the main Arduino module. It will send a trigger signal to the Arduino in the well, receive the measured distance and display the calculated remaining water volume on a display.

2) Well side Arduino and sonar module
The purpose of this Arduino is simply to receive a trigger signal from the house, perform a measurement and send back the distance from the sonar module to the water level. The electronics are built into a (relatively airtight) box, with a plastic pipe attached to the receiving side of the sonar module. The purpose of the pipe is to reduce measurement errors by reducing the field of view so that only the water surface is "seen" by the receiver.

Step 1: Parts, Testing & Programming

We used the following parts in this project:

  • 2 x Arduino (one for measuring fluid level, one for showing the results on a display)
  • A basic 12V power supply
  • Ultrasound (sonar) module HC-SR04
  • LED display module MAX7219
  • 25 m telephone cable (4 wires: Power, ground and 2 data signals)
  • Mounting box
  • Hot glue
  • Solder

Parts cost: About €70

To make sure that everything worked as it should, we did all soldering, wiring and simple bench testing first. There are plenty of example programs for the ultrasound sensor and LED module online, so just we just used them for making sure that the measured distance made sense (picture 1) and that we were able to catch the ultrasonic reflection from the water surface on-site (picture 2). We also did some thorough testing of the data link to make sure that it works ever for long distances, which proved to be no problem at all.

Don't underestimate the time spent on this step, as it is vital to know that the system works before putting effort into mounting everything nicely into boxes, digging down cables etc.

During testing, we realized that the sonar module sometimes picks up a sound reflection from other parts of the well, such as the sidewalls and water supply tube, and not the water surface. This meant that the measured distance suddenly would be much shorter than the actual distance to the water level. Since we cannot simply use averaging to smooth out this type of measurement error, we decided to discard any new measured distances that were too different from the current distance estimate. This is not problematic since we expect the water level to change rather slowly anyway. Upon startup, this module will do a series of measurements and select the largest value received (i.e. the lowest water level) as the most probable starting point. After that, in addition to the "keep/discard" decision, a partial update of the estimated level is used to smooth out random measurement errors. It is also important to allow for all echoes to die out before conducting a new measurement - at least in our case where the walls are made of concrete and therefore very echo-y.

The final version of the code we used for the two Arduinos can be found here:


Step 2: Civil Works

Since our well was located at a distance from the house, we had to create a small trench in the lawn in which to put the cable.

Step 3: Connecting and Mounting All Components

Connect everything as it was during testing, and hope that it still works! Remember to check that the TX pin on one Arduino goes to the RX of the other one, and vice versa. As shown in picture 1, we used the telephone cable to supply power to the Arduino in the well, to avoid using batteries.

The second and third picture shows the plastic pipe arrangement, with the transmitter placed outside the pipe and the receiver placed inside (yes, this was an uncomfortable shooting position...)

Step 4: Calibration

Having made sure that the distance from the sensor to the water level is calculated correctly, calibration was just a matter of measuring the diameter of the well and the total depth so that the fluid volume can be calculated. We also adjusted the algorithm parameters (time between measurements, the partial update parameters, number of initial measurements) to give a robust and accurate measurement.

So how well did the sensor track the fluid level?

We could easily see an effect of flushing the tap for a few minutes, or flushing the toilet, which is what we wanted. We could even see that the well was refilling at a relatively predictable rate overnight - all by just a glance on the display. Success!

- The time-distance conversion is currently not correcting for changes in speed of sound due to temperature variations. This could be a nice future addition, since temperatures in the well will vary quite a bit!



  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge

We have a be nice policy.
Please be positive and constructive.




Hi, this is my first Arduino project so I am probably missing something. The parts list says a 12V power supply. I thought most of these components run off 5V?

It is true that you can run the arduino board off USB 5V. However the board in question has another power input which is connected to a voltage regulator which accepts 7-12V. Running 5v through a 25m thin cable is going to cause a voltage drop over the cable, so the voltage at the arduino in the well is maybe 4.7V. Also, it was infinitely easier to connect power to the dedicated power connector VS somehow connecting 5V to the mini USB. Using 12V optimizes power transmission over the long distance, and was so much easier when everything was to be mounted.

Thanks, makes sense. I only need 7m cable so voltage drop will not be as great, however ease of connection sounds like a significant factor so will probably just buy a board with a voltage regulator and a dedicated power connector. Thanks for your help.

Thanks for sharing this, it has given me a possible solution to an issue we've been trying to solve for some time. I have six bulk lubrication tanks that I need to keep an accurate inventory of. Two of these tanks are 72" tall and while using a tape measure is possible, it is messy and can be inaccurate. This project looks like a possible solution to this issue. My thought is to make a sensor for each of the tanks, then acquire a selector switch which would me to use a single display. Either by pushing a button or turning a knob to select which sensor to display.

So a few questions, is the coding for the depth the sensor will read in the board for the sensor or at the display? As I said the tanks have different heights so I would need a way to have the different depths read correctly. Any idea what type of switches or selector would work for this? I guess I could use a single power supply and power all the sensors and display rather than have to switch power on and off as the selection is being made.

Currently there are Bluetooth enabled sensors but due to the construction of the building and the metal tanks, these are not working well enough to be relied upon.

Thank you for sharing this and for your responses to my questions in advance.

Glad to hear you got inspired!

In this project, all the action is in the Arduino with display. This includes conversion from the mystical time unit that the ultrasound unit gives back to a distance in real units (and further to volume).

In your case, if the tanks are close to each other, you could consider connecting six ultrasound sensors to the "well" Arduino, and have it select which sensor to use based on the trig value ( adding more cases to if (Serial.read() == xxx ) ). Then you can keep track of all fluid levels at once in the Arduino in the house and show the levels sequentially on the display (no need for switch).
If the tanks are further away you could add a switch for the TX/RX pins and have separate Arduinos in each tank, but you would have to reset the Arduino in the "house" after switching tanks with the current code.

Best of luck!

Just wondering, couldn't you run a 1" PVC pipe down the well, and do your ultrasound measurements through it? that may eliminate echoes and give a more precise measurement. I'm no expert, so please let me know if this won't work for any reason.

We did a quick test in open air with the sensor firing inside a long piece of the pipe shown in the pictures (~2 inch). It then returned a constant distance, shorter than the length of the pipe, so we decided not to continue this path. In hindsight we could have tested it more thoroughly (e.g. with water inside the pipe) before dismissing it. Let me know if you decide to try!

Do you think the Ultrasound sensor will last and function properly in that humid environment ? You should've used waterproof sensors, but they are costly. :)

one hand of some eletronic varnish on them (not on the ultra sound sensor, just on the pcb. ) should protect for long time.

I'll update the guide in a year or so when I know for sure!