Water level controller using arduino

praveen October 9, 2014 10 Comments

Arduino water level controller / indicator.

This article is a about a fully functional water level controller using Arduino. The circuit displays the  level of water in the tank and switches the motor ON when the water level goes below  a predetermined level. The circuit automatically switches the motor OFF when the tank is full. The water level and other important data are displayed on a 16×2 LCD display. The circuit also monitors the level of water in the sump tank (source tank). If the level in side the sump tank is low, the motor will not be switched ON and this protects the motor from dry running. A beep sound is generated when the level in the sump tank is low or if there is any fault with the sensors.

Circuit diagram.

arduino water level controller

The circuit diagram of the water level controller using Arduino is shown above. Conductive method is used to measure the level. The sensor assembly consists of four aluminum wires arranged at 1/4, 1/2, 3/4 and full levels in the tank. The dry ends of these wires are connected to analog input pins A1, A2, A3 and A4 of the Arduino respectively. A  fifth wire is positioned at the bottom of the tank. Resistors R6 to R9 are pull down resistors.The dry end of this wire is connected to +5V DC. When the water touches a particular probe, electrical connection is established between that probe and the +5V probe because water has slight conductivity. As a result current flows through that probe and this current is converted into a proportional voltage by the pull down resistor. Arduino reads the voltage dropped across each pull down resistor for sensing the level of water in the tank. Same method is used for measuring the level of water in the sump tank.

Digital pin 7 of the Arduino controls the buzzer and digital pin 8 controls the motor. Transistor Q1 drives the buzzer and resistor R5 limits the base current of Q1. Transistor Q2 drives the relay. Resistor R3 limits the base current of Q2. D2 is a freewheeling diode. POT R2 is used to adjust the contrast of the LCD. resistor R1 limits the current through the back light LED. Resistor R4 limits the current through the power ON LED. Complete program for the water level controller using Arduino is given below.

Program.

#include <LiquidCrystal.h>
int sump=A0;
int qut=A1;
int hlf=A2;
int thf=A3;
int ful=A4;
int motor=8;
int buz=7;
int s;
int q;
int h;
int t;
int f;
int i;     //motor status flag
int v=100; //comparison variable(needs some adjustment)
int b=0;   //buzzer flag
int m=0;   //motor flag
int c=0;   //sump flag

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{

pinMode(qut,INPUT);
pinMode(hlf,INPUT);
pinMode(qut,INPUT);
pinMode(ful,INPUT);
pinMode(sump,INPUT);
pinMode(motor,OUTPUT);
pinMode(buz,OUTPUT);
lcd.begin(16, 2);
digitalWrite(buz,LOW);
}

void loop()
{

i=digitalRead(motor);
s=analogRead(sump);
q=analogRead(qut);
h=analogRead(hlf);
t=analogRead(thf);
f=analogRead(ful);
lcd.clear();

if(f>v && t>v && h>v && q>v )
{
lcd.setCursor(0,0);
lcd.print(char(219));
lcd.print(char(219));
lcd.print(char(219));
lcd.print(char(219));
lcd.setCursor(5,0);
lcd.print("FULL");
m=0;
b=0;
}
else
{
if(f<v && t>v && h>v && q>v)
{
lcd.setCursor(0,0);
lcd.print(char(219));
lcd.print(char(219));
lcd.print(char(219));
lcd.print("_");
lcd.setCursor(5,0);
lcd.print("3/4th");
b=0;
}
else
{
if(f<v && t<v && h>v && q>v)
{
lcd.setCursor(0,0);
lcd.print(char(219));
lcd.print(char(219));
lcd.print("_");
lcd.print("_");
lcd.setCursor(5,0);
lcd.print("HALF");
m=1;
b=0;
}
else
if(f<v && t<v && h<v && q>v)
{
lcd.setCursor(0,0);
lcd.print(char(219));
lcd.print("_");
lcd.print("_");
lcd.print("_");
lcd.setCursor(5,0);
lcd.print("1/4th");
b=0;
}
else
{
if(f<v && t<v && h<v && q<v)
{
lcd.setCursor(0,0);
lcd.print("_");
lcd.print("_");
lcd.print("_");
lcd.print("_");
lcd.setCursor(5,0);
lcd.print("LOW");
b=0;
}
else

{
digitalWrite(motor,LOW);
lcd.setCursor(0,0);
lcd.print("ERROR!");
b=1;
}
}}}
if(i==HIGH)
{
lcd.setCursor(0,1);
lcd.print("Motor ON");
}
else
{
lcd.setCursor(0,1);
lcd.print("Motor OFF");
}



if(s>v && m==1)
{
digitalWrite(motor,HIGH);
}
if(s<v)
{
digitalWrite(motor,LOW);
lcd.setCursor(11,0);
lcd.print("Low");
lcd.setCursor(11,1);
lcd.print("Sump");
c=1;
}
if(s>v)
{
c=0;
}

if(m==0)
{
digitalWrite(motor,LOW);
}

if(b==1 || c==1)
{
digitalWrite(buz,HIGH);
delay(500);
digitalWrite(buz,LOW);
}
else
{
digitalWrite(buz,LOW);
}
delay(100);
lcd.clear();
}

About the program.

The Arduino reads the sensor output through the analog input pins using analogRead function. For example q=analogRead(qut); converts the voltage (in the range 0 to 5V) at the  “quarter” probe into a number (in the range 0 to 1023) and saves it into the variable “q”. This way the voltage at each prob is scanned to corresponding variables. The these variables are compared to a fixed number (100 here) for identifying the current condition. Actually 100 is the equivalent of  0.48 volts  and if the voltage at a particular sensor is greater than this, it is considered as an electrical continuity and water is assumed to be touching the probe. The vale of the fixed number (comparison variable”v”) needs some adjustment because the resistivity of water changes from place to place and the gap between the sensor probes will be different in different tanks.

Notes.

  • The circuit is powered through the 9V external power jack on the arduino board.
  • 5V needed at different points in the circuit can be tapped from the 5V output on the arduino board.
  • Use good quality aluminum wires for probe. Do not use copper wires.
Comments
  • Shiharan Choudhury
    November 27, 2016

    HI.

    Using conductive method for sensing the water level is a BAD option. Why i say that? Because over time the water would corrode the metallic area that stay immersed all the time in the water, so over time false sensing is what we face.

    We can use the RADAR technology for it. It means we will generate a few high frequency pulses and transmits it towards the target whose distance is to be measured. Then we detect the bounced back waves and calculate the distance. And none the less whatever RAW data we receive, we can process that to switch things & display text on display’s.

    So going with the ultrasonic sensor is the way. HC-SR04

  • RAMESH
    August 28, 2015

    dear,
    really, this ckt is very good ,i tried somany ckt from circuit today ,i found all r working perfactly,and hope this ckt als working ,not yet tried.
    Ramesh

  • Chetan
    May 21, 2015

    your description is fine but i have some query that which relay is suitable to drive 1hp self priming monoset pump and how connection can be made?
    tell me its urgent….,

    • sathyamoorthy
      July 19, 2015

      you can use the relay mentioned in the circuit to control a coil controlled isolator(CCI) used in AC circuits. The relay will control the coil side of the isolator and the contacts will take care about the AC load. it will look like a MCB with additional AB contacts for the Coil. route the Coil circuit through the 9 V relay contacts.

  • zobi_97
    January 25, 2015

    Hi! I am new to the world of electronics and wish to make a similar circuit. Could u please help in suggesting a simple, cheapest, durable and an automated solution (with maximum safety) for prototyping the circuit below? Thank You !

    I have two AC motors, one for storing water in underground tank and the other for filling up overhead tank.
    I start storing water in the underground tank once it comes during designated timings on alternate days only and it takes 8-10 hrs for tank to fill completely.
    Sometimes it even happens that pump for underground tank is left running (not knowingly) and the water supply from utility during the designated timings is over while filling up the tank. In this scenario, the motor uselessly runs, until someone physically see the the flow of water and then switches it off.
    After I see that there is substantial amount of water present in the sump, then only i switch on the other motor to fill up overhead tank or it would burn down the motor. The tank fills up in 90mins, if it’s completely empty. In this scenario too, one has to be there in time to switch off the motor once it has filled up completely to prevent overflow.
    For this circuit, I would like to know the level of water using 5 LED indicators (EMPTY, 1/4, 1/2, 3/4, FULL) for both of my tanks.
    More importantly, a manual switch in the circuit would be its plus point. So that if the circuit is malfunctioning, I would be able to connect the motors directly to mains.

    Both are 2 HP motors and operate in 220V AC

  • sanjeev
    January 7, 2015

    What is the use of another tank below the main tank shown in figure

    • jojo
      January 7, 2015

      @sanjeev – It is sump tank used to represent water source (say well or a pond). If the level in side the sump tank is low, the motor will not be switched ON and this protects the motor from dry running.

  • S.yogaraj.
    November 6, 2014

    Sir,
    What is the Maximum length of the sensor wire of the aluminium sensing rods from the over head tank, we can use for the inputs to the arduino .

  • October 30, 2014

    can we use any other sensing arrangement for this circuit ?

  • sanjay jhaveri
    October 12, 2014

    we require PCB for Water level controller using arduino c

Leave a Reply to RAMESH Cancel reply

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