Instructables

Arduino dual ultrasonic liquid level meter with integrated website

Picture of Arduino dual ultrasonic liquid level meter with integrated website
DSC_0499.JPG
DSC_0500.JPG
DSC_0504.JPG
IMG_5382.JPG
IMG_5375.JPG
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 (http://www.jo3ri.be/) Check this site for more information about the included webserver
- Erik DC
- Wim DB

http://www.arduino-jam.org/
 
Remove these adsRemove these ads by Signing Up

Step 1: Main module

Picture of Main module
DSC_0508.JPG
DSC_0500.JPG
DSC_0489.JPG
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 (https://www.sparkfun.com/products/9132), that takes care of the 3.3 to 5V conversion, and receives the data from the wireless sensor.


Step 2: The wireless XBee sensor

Picture of The wireless XBee sensor
DSC_0501.JPG
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
  PWM_Mode_Setup();
  pinMode(URTRIG1,OUTPUT);           
  Serial.begin(9600);
}

void loop(){  
   if(millis()-urmTimer>1000){
     urmTimer=millis();
     PWM_Mode();
   }
}

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);
  
   if(DistanceMeasured1<49000){                   
      digitalWrite(13,LOW);
      Distance1=DistanceMeasured1/50;                  // every 50us low level stands for 1cm
   } else {
     Distance1=0;
     digitalWrite(13,HIGH);
   }
  

  if ((Distance1 > 3) && (Distance1 < 400)) {
    Serial.print(Distance1);
    Serial.print("-");
  }
}

Step 3: Configuration

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


sujithn1 year ago
Great project
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.
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 ;-)
JO3RI1 year ago
Being a member of the team on the arduino-jam, I continue this project on my own website. For now I finished a wired version, with wired only sensors. Later on you will be able to set this up in the config page. Go have a look http://www.jo3ri.be/a/jo3ri.be/jo3ri/arduino/projects/tank-level-measuring-basic
nice, what was your reason for designing this interface? What do you think the accuracy of these ultrasonic sensors is?
The main reason was to monitor 2 Diesel containers locked away in the cellar.
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.

Erik