IONOTS

Automatic water level controller

In this project, you will learn how to control a water level a in the tank automatically using Arduino and a Ultrasonic sensor

Problem

A lot of water gets wasted during tank filling and we sometimes run out of the water.

Solution

Here we have a simple economical water level controller that comes up solving all those problems. It monitors the water level in the tank and operates
the pump accordingly and saves water as well as power and prevents the tank from running out of the water.

Requirements:

5v power adapter
arduino nano or Arduino Uno
connecting wires/jumper wires
ultrasonic sensor(HC SR04)
a single channel relay module

Construction:

NOTE:  Common pin and NO/NC pins may vary according to the type of relay manufacturer

Process:

Here we continuously measure the distance of water using an ultrasonic sensor and an Arduino microcontroller.
When the distance of water is less than the minimum level, immediately microcontroller will turn on the relay and it activates the motor and waits until the water level reaches the max level and then it automatically turns it off.

Code:

const int trigPin = 3;  //arduino pin 3 to ultrasonic trig
const int echoPin = 2;  //arduino pin 2 to ultrasonic echo 
const int relay = 4;  // ardino pin 4 to relay IN pin
const int min_level = 15;  //min water distance in cm
const int max_level = 300;  // maximum water distance in cm
//note: change min and max levels according to your tank level

void setup() 
{ 
Serial.begin(9600);   // for serial monitor 
pinMode(trigPin, OUTPUT);  
pinMode(echoPin, INPUT);
pinMode(relay, OUTPUT);
} 
void loop()
{
long duration,cm;
digitalWrite(trigPin, LOW); 
delayMicroseconds(2); 
digitalWrite(trigPin, HIGH); //triger for 10us to observe eco
delayMicroseconds(10); 
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH,3); // wait for 3 sec to get the pulse 
cm = microsecondsToCentimeters(duration); // call distance measuring function
Serial.print(cm);  // print distance on monitor when connected 
Serial.print("cm"); 
Serial.println(); 
if (cm >= max_level){     // condition if level is high
digitalWrite(relay, HIGH);   
Serial.print('pump OFF');
}
if(cm <= min_level){       // condition if level is low
digitalWrite(relay, LOW);
Serial.print('pump ON');
}
delay(1000);
}

long microsecondsToCentimeters(long microseconds) // to caliculate distance in cm
{return microseconds / 29 / 2;}

 

 

–ABHIJITH

Share this post

Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on whatsapp