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!


murfmv (author)2017-09-10

what is the circuit board connected to the sensor for the well in step 3?

pgs070947 (author)murfmv2017-09-13

Bluetooth doesn't have a great range.

You have a choice of AM/FM radios (depending on country) operating on 433 or 868 MHz if you wanted to go wireless. 433 has the greatest penetration.

I quite like ZigBee (Digi XBee for example) which are relatively easy to set up and can cope with analogue and digital inputs.

Six might be too many for analogue, digital no problem. You might be able to poll each tank.

Oil is a messy medium for any contact method. Do you have sight glasses?

Domestic oil tanks have remote contents devices, but I don't know what the transmission medium is.

One slight concern might be the effect of volatiles from the oil.

hertzclone (author)pgs0709472017-09-14

I assume your response was directed to my questions/comments. Agreed the Bluetooth did not work, I'll look into the AM/FM as you suggest. There are no sight glasses, and the tall tanks have a capacity of 2000 gallons so there are quite large. As I can get weekly deliveries the tanks will likely never have more that 28: of product in them. So the sensors will be quite a distance from the oil. There are threaded bungs on the top of the tank, my thought is to use a male threaded plug, drill and mount the sensor to it and the Arduino would be outside the tank.

pgs070947 (author)hertzclone2017-09-14

Yours is a tricky one given the medium. If you can get a look at textbook Practical Arduino, it gives details of a project using a pressure sensor. One of the main problems is diffusion in or out of the connecting tubing pipework. Given that yours sounds like a commercial set-up, you could look at stainless or copper tubing. The thing that would worry me is the effect of oil vapours, and not least, any flammability issues. If you kept the measuring stuff outside the tanks, you could mitigate that. A well engineered dip tube from the top for pressure might work or there is the tried and tested float and pulley method.

karlli (author)murfmv2017-09-11

Do you mean the Arduino itself?

murfmv (author)karlli2017-09-11

After closer inspection it seems that is an Arduino board. Never saw one that looks like . The photo looking up at the sensor. It seems that the cone is only around the one sensor. Is that true. Also a diagram or drawing of that cone would be nice. How about the specs on the distance that sensor can reach?
Great job though!

parth_bhat (author)2017-09-13


I don't know since how long your using it but have you faced an issue of the ultrasonic sensor getting damaged because of the moisture from the water?

Parth Temkar

hertzclone (author)2017-09-12

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.

ihart (author)2017-09-11

Great project!

Another distance sensor that will give accurate results without ultrasound reflection issues is the laser based Lidar Light. I have used it with an Arduino and setup is very fast with their sample code.

(Shortened link. Thanks nh4x4Jeep!)

instig8r (author)2017-09-10

Nice job! How many parts did you drop down in the well before you were done? ::-)

karlli (author)instig8r2017-09-11

Haha I guess we were lucky (and cautious) on this one!

DIY Hacks and How Tos (author)2017-09-08

Great monitoring system. Do you have any automatic alerts set up with it?


Not at the moment. We haven't been close to empty yet and the display is quite centrally located in the house so I think we'd notice if the level drops too much!

ItsGraGra (author)2017-09-10

These sensors have 'ping' and 'echo' connections.

Why are you not using the 'echo'.

You could also use the NewPing library, better timing and simpler code. get here:

Water roof sensors are available with board for about US$5 on Aliexpress:

And if you're not using WiFi, why 2 Arduinos? Run your sensor wires (4) direct to the Arduino in the house.

karlli (author)ItsGraGra2017-09-11

We are definitely using the echo pin, this is the one sending the distance info back to the Arduino. It's not possible to have a 25m cable between the Arduino and the sensor. We tried :)

Roman_Policier (author)2017-09-08

Why did you used 2 arduino board ? I do one for 7€

karlli (author)Roman_Policier2017-09-11

Because of the distance between the sensor and the display. Neither the sensor-to-Arduino nor the Arduino-to-display interface would work with a 25m cable.

vishnumaiea (author)2017-09-09

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. :)

karlli (author)vishnumaiea2017-09-11

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

MikeD11 (author)2017-09-10

This could have lots of uses! Great idea. You might want to dip the electronics in epoxy to water proof it but don't get epoxy on the sensors.

karlli (author)MikeD112017-09-11

Thanks for the tip! I didn't mention this in the instructions, but I used hot glue to seal the electronic boxes as well as I could to prevent moisture issues.

pgs070947 (author)2017-09-10

I used to use a lot of ultrasonic sensors in the waste water business - the nature of the medium meant that non-contact was the preferred method.

Long-term ultrasonics are generally weather-proof and being designed for industrial set-ups, but have a hefty price tag.

I used cheaper non-waterproof sensors, but weather-proofed them myself using PVC pipework as a shield which was fine as the sensors always pointed down.

The biggest problem was unexpected - spiders loved them, maybe there was a little warmth there, but a thick web soon caused problems. I could have devised a method to evict them, but that would be mean, so regular cleaning was appropriate.

I didn't find any problems with sidewall reflections, in fact the pipe seemed to concentrate the beam and extend the range. Nor was the dampness a problem, just avoid direct wetting.

Nice, useful project.

karlli (author)pgs0709472017-09-11

Thanks for sharing! We've not had any spider problems so far but I will definitely check for that if we get issues.

About This Instructable




More by karlli:Ultrasound Tank Level Meter
Add instructable to: