in

Water level detector using ultrasonic Sensor

Arduino with ultrasonic sensor HC-SR04

Welcome to the Quanta project. in this project, we will measure the water level using the ultrasonic sensor and the Arduino Uno r3. by using this project you measure water level, the fuel level in any container. only you have to put the ultrasonic sensor at the top side of the container. so, it can measure the distance between the ultrasonic sensor and the water inside the container. you can use this project at your overhead tank and in your bike fuel tank. if your overhead tank full then it will notify you or you can just turn off the water pump. you can use this for many applications as per your requirement.

How it’s work?

there is an ultrasonic sensor which works on the ultrasonic waves. it has two main components inside the sensor one is transmitter and another is a receiver. we connect the transmitter to the output pin of the Arduino and the receiver pin is to be connected to the input pin so we can receive the data as the input.

so the wave transmitted by the transmitter comes back after the incident on any object and in this projects the waves incident on the water. and then we calculate the distance by the time duration to comes back the waves.

so this is the basic principle of the project. at this principle, w measure the distance between the ultrasonic sensor and the water inside the container

Components Require to make water level detector:-

  •  Arduino Uno
  • Ultrasonic sensor
  • LCD display
  • Wires
  • Switch

Circuit diagram for water level detector:

 

Code for Water level detector :

#include <LiquidCrystal.h>#include<SoftwareSerial.h>

SoftwareSerial mybt(2,3);

int s,q,p,z;

const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int duration_front=0;

long distance_front=0;

void setup() {

lcd.begin(16, 2);

pinMode(4,OUTPUT);

pinMode(5,INPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(A1, INPUT);

mybt.begin(9600);

Serial.begin(9600);

}

void loop()

{

digitalWrite(4, HIGH);

delayMicroseconds(10);

digitalWrite(4, LOW);

delayMicroseconds(2);

duration_front= pulseIn(5,HIGH);

distance_front=duration_front*0.034/2;

int s = map(distance_front, 0, 12 , 0,  120);

int p =  map(s, 120, 0 , 0,  1200);

Serial.println(p);

mybt.write(distance_front);

lcd.setCursor(0,0);

lcd.print(“Water level =”);

lcd.print(p);

delay(10);

int q= analogRead(A1);

if(q >= 800)

{

digitalWrite(6, HIGH);

digitalWrite(7, HIGH);

lcd.setCursor(0,1);

lcd.print(“water pump ON”);

}

else

{

digitalWrite(6, LOW);

digitalWrite(7, LOW);

lcd.setCursor(0,1);

lcd.print(“water pump OFF”);

}

}

Upload the given code into the Arduino with the IDE

What do you think?

0 points
Upvote Downvote

Written by shahid

Leave a Reply

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

Single Axis Solar Tracker using Arduino

Pravid 2019 – National Level Science Exhibition