
Liquid level measurement in process tanks for monitoring and/or control is essential in process industries. In process plants, tanks hold a variety of usually expensive liquids. Some liquids are also flammable and corrosive. Therefore, it is very important to monitor the level of liquid in a tank so that it does not overflow from the tank.
In this project, we will build a bottle water level measurement system based on the Arduino board.
We know that water, like any other liquid, is a conductor of electric current.
The detection of the level of water filled in the bottle is based on this idea.
When the water level rises, this liquid comes into contact with the end of the connection wire fixed in the bottle, the electrical circuit is then closed and a very low voltage electrical current is detected by the Arduino board.
When the water level drops, the electrical circuit is open. As a result, there is no more electric current.
Then the Arduino board displays the water level on the LCD display.
Connecting wires
4 resistors of 10Kohm
First We drill 5 holes in the bottle. Then we fix a connection wire in each hole.
Then we connect:
the lowest jumper wire to the 5V pin of the Arduino
the 2nd wire connecting to pin A0 of the Arduino
connecting the 3rd wire to pin A1 of the Arduino
connecting the 4th wire to pin A2 of the Arduino
the 5th jumper wire to pin A3 of the Arduino
For the I2C LCD 1602 display we connect:
the SDA pin to the A4 pin of the Arduino
the SCL pin to the A5 pin of the Arduino
the GND pin to the GND pin of the Arduino
the VCC pin to the 5V pin of the Arduino
Voici le programme Arduino qui permet de détecter le niveau d’eau remplie dans la bouteille et afficher le niveau d’eau sur l’afficheur LCD.
Il faut télécharger ces deux bibilothèques : LiquidCrystal_I2C et LcdBarGraphRobojax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
#include <LiquidCrystal_I2C.h> #include <LcdBarGraphRobojax.h> LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display LcdBarGraphRobojax lbg(&lcd, 16, 0, 0); int analogA0 = A0; int analogA1 = A1; int analogA2 = A2; int analogA3 = A3; int level_1,level_2,level_3,level_4; //analog readings int niveau=30; int send_0; int send_1; int send_2; int send_3; int send_4; void setup() { lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); send_0=0; send_1=0; send_2=0; send_3=0; send_4=0; Serial.begin(9600); pinMode(analogA0,INPUT); pinMode(analogA1,INPUT); pinMode(analogA2,INPUT); pinMode(analogA3,INPUT); } void loop() { // Read the analog interface level_1 = analogRead(analogA0); level_2 = analogRead(analogA1); level_3 = analogRead(analogA2); level_4 = analogRead(analogA3); Serial.print("niveau 1 "); Serial.println(level_1); Serial.print("niveau 2 "); Serial.println(level_2); Serial.print("niveau 3 "); Serial.println(level_3); Serial.print("niveau 4 "); Serial.println(level_4); if ((level_1<niveau)&&(level_2<niveau)&&(level_3<niveau)&&(level_4<niveau)&&(send_0==0)){// Niveau 0 de l'eau lbg.clearLine(1);// clear line 1 to display fresh voltage value lbg.drawValue( 0, 1024); // Display level 0 on the LCD display send_0=1;send_1=0;send_2=0;send_3=0;send_4=0; } if ((level_1>niveau)&&(level_2<niveau)&&(level_3<niveau)&&(level_4<niveau)&&(send_1==0)){ // Niveau 1 de l'eau lbg.clearLine(1);// clear line 1 lbg.drawValue( 256, 1024);//Display level 1 on the LCD display send_0=0;send_1=1;send_2=0;send_3=0;send_4=0; } if ((level_1>niveau)&&(level_2>niveau)&&(level_3<niveau)&&(level_4<niveau)&&(send_2==0)){ // Niveau 2 de l'eau lbg.clearLine(1);// clear line 1 lbg.drawValue( 512, 1024);// Display level 2 on the LCD display send_0=0;send_1=0;send_2=1;send_3=0;send_4=0; } if ((level_1>niveau)&&(level_2>niveau)&&(level_3>niveau)&&(level_4<niveau)&&(send_3==0)){ // Niveau 3 de l'eau lbg.clearLine(1);// clear line 1 lbg.drawValue( 768, 1024);// Display level 3 on the LCD display send_0=0;send_1=0;send_2=0;send_3=1;send_4=0; } if ((level_1>niveau)&&(level_2>niveau)&&(level_3>niveau)&&(level_4>niveau)&&(send_4==0)){ // Niveau 4 de l'eau lbg.clearLine(1);// clear line 1 lbg.drawValue( 1024, 1024);// Display level 4 on the LCD display send_0=0;send_1=0;send_2=0;send_3=0;send_4=1; } lcd.setCursor(2,1); lcd.print("Water level"); delay(100); } |