Automatic Water Pump Controller
by SriHarsha Reddy in Circuits > Microcontrollers
445 Views, 0 Favorites, 0 Comments
Automatic Water Pump Controller
Water is the basic need and it is one of the most important necessities for all living beings. Hence, it is of utmost importance to preserve water. In many houses and offices there is unnecessary wastage of water due to overflow in overhead tanks.Here we Introduce an Automatic water pump controller using Arduino and Ultra sonic sensor which use to turn on/off of water pump.
HC-SC04 Sensor
Here we use HC-SR04 Ultra sonic sensor which we define the measurements of the tank which is our water storage tank. The sensor gives the measurement of length of the tank is 120cm or 110cm then starter is On Condition and the length of the tank is less than 5cm then motor Off Condition.
Connections
connect sensor and Relay to the arduino and connect the Relay1 to start button of the starter and connect relay2 to stop button of the starter.
Note:
From the connection Picture i am choosen two Pushbuttons instead of Starter Start/Stop buttons.
Code
int echoPin = 12; //Define Echo pin
int trigPin = 13; // Define Trig pin
int Relay = 2;
int Relay2 = 4;
int motorOn = 0;
int powerOn=0;
long duration, cm; //Define variables
int height=122; //define depth of tank in cm
void setup()
{
digitalWrite(Relay, HIGH);
digitalWrite(Relay2, HIGH);
Serial.begin (9600);
pinMode(trigPin, OUTPUT); //Define output pin
pinMode(echoPin, INPUT); //Define input pin
pinMode(Relay,OUTPUT); //Define output pin
pinMode(Relay2,OUTPUT);
delay(2000);
powerOn=1;
}
void loop()
{
if(powerOn==1)
{
delay(900000);
}
powerOn=0;
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW); // Read the signal from the sensor
duration = pulseIn(echoPin, HIGH); // convert time into a distance
// The speed of sound is 29.1 microseconds per centimeter.
cm= duration*0.034/2;
Serial.print(cm);
Serial.print("cm");
Serial.println();
if (cm<=120 && cm >= 100 && motorOn == 0) // water level is low
{
//Imitation of switch
digitalWrite(Relay, LOW); // Motor on
delay(15);//15 milli second
digitalWrite(Relay, HIGH);
motorOn = 1;
Serial.print("On");
}
else if (cm >=5 && cm <= 30) // water level is high
{
digitalWrite(Relay2,LOW);
delay(5000);
digitalWrite(Relay2, HIGH); // motor off
motorOn = 0;
Serial.print("Off");
}
delay(10000);
}
Cost Estimation
Microcontroller atmega 328p : 260
Relay : 3 relay module : 150
HC Sr 04 sensor : 120
Pcb : 50 Fuse : 2 * 20=40
Crystal =12
capacitors
microcontroller holder
Caution:
-->Be careful while doing work on Starter connections.