Arduino Projects

Water level monitoring using Ultrasonic Sensor | Water Tank level monitoring

Water level monitoring:

 

Water level monitoring using Ultrasonic Sensor | Water Tank level monitoring- In this tutorial, you will learn how to make a Water level monitoring system using Arduino, ultrasonic sensor, and some LEDs. The LEDs are used to show the percentage of water available in the Water tank. This is a beginner’s level project explaining the basics. While the recent version of the water level monitoring system is based on the Nodemcu esp8266 wifi module to monitor the water level on my cell phone and also control the water pump from anywhere around the world, So the IoT version of the Water level monitoring system entirely depends on this tutorial. So I highly recommend you should read this article to the end. This Tutorial covers

  1. Ultrasonic Sensor based Water Level Monitoring System Circuit Diagram Explanation
  2. Ultrasonic Sensor Interfacing with Arduino
  3. Water level monitoring Arduino Programming and finally
  4. testing

Recently, I designed another IoT-based water level monitoring using TOF10120 Laser Range Finder Sensor.

read my article on Wireless water level indicator “communication range 1.5Km.

You can also ready my article on IoT based Water level monitoring and automatic water pump control system using the ESP32 WiFi + Bluetooth Module, Waterproof Ultrasonic Sensor, and the New Blynk V2.0 more…

Without any further delay, let’s get started!!!


Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

HC-SR04 Ultrasonic Sensor:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

HC-SR04 Ultrasonic Sensor:

Water level monitoring

This is the HC-SR04 Ultrasonic Sensor. As you can see the pins are clearly labeled with VCC, trigger Echo and ground. I have a very detailed getting started tutorial on how to use the HC-SR04 ultrasonic sensor with Arduino. You can simply search for the Ultrasonic Sensor, you will get a complete list of all the projects in which I have used the Ultrasonic Sensor.


Water level monitoring Circuit Diagram:

Water level monitoring

This circuit is designed in cadsoft eagle 9.1.0 version. if you want to learn how to make a schematic and pcb then watch my tutorial.

As you can see the circuit diagram of the water level monitoring system is really simple. The trigger pin of the ultrasonic sensor is connected with pin number 7 of the Arduino. While the echo pin of the ultrasonic sensor is connected with pin number 6 of the Arduino.

the VCC and GND pins of the ultrasonic sensor are connected with the Arduino’s 5v and ground pins. These are the 5 led’s which will be used to display the percentage of water available in the water tank. The first led will show 20%, the second led will show 40%, and so on. So the last led will show 100%.

These are the current limiting resistors which are connected in series with these 2.5v LEDs. I have a very detailed tutorial on how to calculate the value of the current limiting resistor.


Soldering & Interfacing:

For the Soldering and Interfacing watch video tutorial gave at the end of this Article.

Water level monitoring Arduino Programming:

// Arduino programming

#define trigpin 7  
#define echopin 6 

The trigger pin is connected with pin number 7 and the echo pin is connected with pin number 6 of the Arduino.

int led1 = A0; 
int led2 = A1; 
int led3 = A2; 
int led4 = A3; 
int led5 = A4; 

Then defined pins for the led’s which are connected with analog pins A0 to A4. Total of 5 led’s are used in this project. if you want you can increase and decrease the number of led’s as per your requirement.

As you know my friends every Arduino and Mega program has at least two functions, which are the void setup and void loop functions. Void means that these functions are not returning any value while the empty parenthesis means that these functions are not taking any arguments as the input.


void setup()
{
Serial.begin(9600);
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
  pinMode(led1, OUTPUT); 
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);

The trigger pin is set to output while the echo pin is set to input. Set all the leds to output using the pinMode function. Turn off all the led’s using the digitalWrite function.

 delay(1000); 
}

void loop()
{
 int duration, distance;
 digitalWrite(trigpin, HIGH);

delayMicroseconds(1000);  
digitalWrite(trigpin, LOW);


duration = pulseIn(echopin,HIGH);

distance = ( duration / 2) / 29.1;
Serial.println("cm:"); 
Serial.println(distance);


if(  (distance > 0) && (distance <= 10)   ) 
{
  digitalWrite(led1, HIGH); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH); 
} else
if(  (distance > 10) && (distance <= 20)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH); 

} else

if(  (distance > 20) && (distance <= 30)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH);
} else

if(  (distance > 30) && (distance <= 40)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH);
} else

if(  (distance > 50) && (distance <= 60)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH);
} else

if(  distance > 60 ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
} 

}

defined two variables with the names duration and distance. Turns on the trigger pin for 1000 microseconds and then turn it off. . then using this formula we find the distance in centimeters. The rest of the programming is very simple and is only consists of the if conditions. The led’s are turned on and turned off depending on the distance of the water level from the ultrasonic sensor. The Values used in these if conditions can be changed as per your requirement. The type of the ultrasonic sensor I am using is capable of measuring the distance up to 5 meters.


Watch Video Tutorial:

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

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

Back to top button