WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR

WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR

Hello guys, welcome back to another tutorial from SriTu Hobby. This tutorial includes how does work the Water level sensor with Arduino. Also, this tutorial covers how to measure water levels using a water level sensor and display those values on the LCD Display. We can monitor factors such as water levels, leaks, and rainfall through this sensor.

WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR

How does this sensor work?

In this sensor, we can see 10 copper straps. 5 of them are power straps and the other 5 are sensory straps. This sensor also works in the same way as the Rain sensor and Soil moisture sensor we have presented in previous articles. You can study them at the links below.

This water level sensor also acts as a variable resistor. The resistance varies according to the amount of water. The resistance value is inversely proportional to the height at which the sensor is submerged in water. When the sensor is submerged in more water, it has better conductivity and less resistance. Also, when the sensor is submerged in low water, it has a higher resistance due to its weak conductivity. In this sensor, we can see three main pins. They are described below.

  • Signal – We can get the water level as an analog value.
  • VCC – This pin should have a potential of 3.3v to 5v.
  • GND – Ground of this sensor.
WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR

OK, let’s learn how to use this sensor with Arduino. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

OK, Let’s do this project step by step.

Step 1

Firstly, identify these components.

Step 2

Connect these components using the circuit diagram below.

WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR

Step 3

Now let’s create the required program. First, download the I2C library and include it in the Arduino IDE.

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
}
void loop() {
  int value = analogRead(A0);
  lcd.setCursor(0, 0);
  lcd.print("Value :");
  lcd.print(value);
  lcd.print("   ");
  Serial.println(value);
  lcd.setCursor(0, 1);
  lcd.print("W Level :");


  if (value == 0) {
    lcd.print("Empty ");
  } else if (value > 1 && value < 350) {
    lcd.print("LOW   ");
  } else if (value > 350 && value < 510) {
    lcd.print("Medium");
  } else if (value > 510){
    lcd.print("HIGH  ");
  }
}

code explanation

The first line of this code includes the I2c library. Then create an object in that library as “lcd” and give the I2c address and the length and width of the LCD we are using.

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

Then serial monitor and I2C communication begin in the void setup. Also, the backlight of the LCD is turned on.

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
}

In the void loop, reads the sensor value and inserts it into the variable “value”. It then displays on the LCD and the serial monitor.

  int value = analogRead(A0);
  lcd.setCursor(0, 0);
  lcd.print(“Value :”);
  lcd.print(value);
  lcd.print(”   “);
  Serial.println(value);
  lcd.setCursor(0, 1);
  lcd.print(“W Level :”);

Finally, those values are checked using the IF condition and the result is printed on the LCD as low, medium, and high.

  if (value == 0) {
    lcd.print(“Empty “);
  } else if (value > 1 && value < 350) {
    lcd.print(“LOW   “);
  } else if (value > 350 && value < 510) {
    lcd.print(“Medium”);
  } else if (value > 510){
    lcd.print(“HIGH  “);
  }

Step 4

OK, select the board and port. After, click the upload button.

Now, you can test this project. The full video guide is below. So, we hope to see you in the next tutorial or project. Have a good day.

WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR

8 thoughts on “WATER LEVEL SENSOR Tutorial| How to use WATER LEVEL SENSOR”

  1. I want to add a 5v water pump to this setup that starts when the water level sensor is 50 and stops when the water level is 450. Can you help with that?

  2. C:\Users\Sainath B\Downloads\Water_level_sensor\Water_level_sensor.ino:1:10: fatal error: LiquidCrystal_I2C.h: No such file or directory
    #include
    ^~~~~~~~~~~~~~~~~~~~~
    compilation terminated.

    exit status 1

    Compilation error: LiquidCrystal_I2C.h: No such file or directory

    It shows this error please help me out as soon as possible

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Select your currency
USD United States (US) dollar
EUR Euro
Scroll to Top