Arduino Dual Ultrasonic Liquid Level Meter With Integrated Website




This project allows you to monitor the level of 2 containers filled with liquid. The levels can be shown on a website. The example below has one sensor connected by wire, and another sensor connected wirelessly by XBee.

The website allow you to configure the minimum and maximum levels (for a full and empty tank), so the level can be shown in percentage. Also the tcp/ip settings can be configured.

This project was created at the second Belgian Arduino Jam Gent by:

- Jo3ri  C ( Check this site for more information about the included webserver
- Erik DC
- Wim DB

Step 1: Main Module

The main module is composed of an Aduino Ethernet board (or an arduino with Ethernet shield).

Directly attached is the URM37 ultrasonic sensor from DFRobot (ethernet cable is used as extension lead). The URM37 is used in TTL mode, so only 4 wires are need (2 for power + 2 for data)

Also on the main board is the XBee Explorer (, that takes care of the 3.3 to 5V conversion, and receives the data from the wireless sensor.

Step 2: The Wireless XBee Sensor

Since we had some 'barebone arduino'  (ATMEGA 328P-PU with bootloader) laying around, we choose to use this for the remote sensor.

Xbee's DIN and DOUT are connected to D0 and D1 on the arduino, so the build--in Serial can be used.

The sketch running on it is very simple, it reads out the URM37 (connected to pin 2 and 3), and transmits the distance in cm through serial to the Xbee.

int URPWM1=2;             // PWM Output 0-25000us,every 50us represent 1cm
int URTRIG1=3;             // PWM trigger pin
unsigned long urmTimer = 0;                          // timer for managing the sensor reading flash rate

unsigned int Distance1=0;

void setup(){                                      // Serial initialization
                            // Sets the baud rate to 9600

void loop(){  

void PWM_Mode_Setup(){
  pinMode(URTRIG1,OUTPUT);                            // A low pull on pin COMP/TRIG
  digitalWrite(URTRIG1,HIGH);                         // Set to HIGH 
  pinMode(URPWM1, INPUT);                             // Sending Enable PWM mode command


void PWM_Mode(){                                     // a low pull on pin COMP/TRIG  triggering a sensor reading
    digitalWrite(URTRIG1, LOW);
    digitalWrite(URTRIG1, HIGH);                      // reading Pin PWM will output pulses
    unsigned long DistanceMeasured1=pulseIn(URPWM1,LOW);
      Distance1=DistanceMeasured1/50;                  // every 50us low level stands for 1cm
   } else {

  if ((Distance1 > 3) && (Distance1 < 400)) {

Step 3: Configuration

The website on the arduino allows you to configure the TCP/IP data, as well as the minimum / maximum levels of your tank.



  • Fandom Contest

    Fandom Contest
  • Beauty Tips Contest

    Beauty Tips Contest
  • Frozen Treats Challenge

    Frozen Treats Challenge

15 Discussions


3 years ago on Introduction

hello all, good project and well explianed thanks. I stumbled on this whilst researching something for my own project. I've built a similar thing to this on the raspberry pi. It would have saved me quite a bit of time if i'd have found this instructable first. However maybe our paths cross at the right point. My next aim is to make mine non intrusive thus the ultrasonic transducers are clamped glued or magnetitcally attached to the tank. My theory is it is still tof but ignore the first few reflections off the metal tank wall. However this is where i get stuck (thus the research). Have you tried to do somethign like this ?

Note to get rid of wave on the liquid interfering with the readings just average out over a set of readings. For me the level change is very slow so I can easily do an average of 100 readings. Thanks agian

2 replies

Reply 2 years ago

Hi i am also interested in whether or not it would attach the sensor directly to the container wall. Have you tried this yet and is it possible?


Reply 2 years ago

I haven't tired it yet but yes it is very much possible. It is just about getting the right power and type of transducer. For example if your tank is insulted (acoustically speaking) from the surroundings you can bash it with any object and it will ring with a certain frequency . The frequency will change depending on how full it is. So this should be equally possible with a controllable exciter but ultrasonic or not I'm not sure...

I am using this to fill overhead tank of my home, the only problem I find is it becomes tricky when the water moves inside the tank. The waves / ripples inside the tank will send in incorrect readings. Especially when the pump is on and its filling the water tank.

The ultrasonic sensor is very cheap costs around $2 so replacing the damaged sensor is not a hassle.


4 years ago on Introduction

I have a question. The ultrasonic sensors may get damaged due to moisture inside the overhead tank. What solution do you suggest for this problem?


4 years ago on Introduction

we have 24 over head tanks and we would want min # and cost of sensors to deal with auto start and auto on of motor pump that starts as and when any tank is low on water and shuts complete when all water tanks are filled. Can we get this solution with your work ? tanks are on above 2nd floor of houses and motor pump on ground floor.


4 years ago on Step 3


This is brilliant, really want to make one, please can you share the magic. Can you send me a link to download the code.

Web interface is great :)

Well done Dans

Great project guys! And congrats with the 2nd place ;-)
In my eyes, this was a winner! It has a wide field of potential uses. We can't say that about the bike-project, however it was a nice one too :)

Just one question:
What if the liquids container goes conical or rounded to the bottom?
It would be a nice extra if those variables are integrated in the setup (measuring) section to get an accurate readout of the remaining liquid.

2 replies

Well, for most containers it doesn't really matter that much, but one could go with different calculations, mind you, they would be different for every container.

That last statement was my point... and the challenge ;-) But I'm thinking outside the project, so never mind ;-)

You mean the webinterface ?

We already had the website from another project, so we decided to re-use it for this purpose.

It is accurate to at least 1cm. for the purpose of measuring liquid levels in big containers this is plenty...

The biggest advantage of ultrasonic measuring is that it is not invasive, it does not touch the liquid, and it has no moving (or corroding) parts.