Hi All, welcome to yet another Arduino project from TexoBot. This time, we will learn how to create a Fully Automatic Water Tank Level Controller with DRY PUMP RUN PROTECTION feature.
Last time we did another video on this topic using Ultrasonic sensor. We are publishing this video upon the special request from our viewers.
without any further ado let's get started.
Table of Contents
Let’s learn the Designing and Working of this project using given block diagram.
Arduino is the brain of this project. It will take input from the sensors and control all other units according to the value received.
This unit will display the Water Level in percentage as well as in Bar Diagram, it will also show the Pump status. This section will also notify us whenever the Sump tank is empty.
This is used to measure the water level present in the overhead water tank. These are five copper wires which are dipped into the Overhead Water Tank.
Let’s understand the working principle of the Wire Sensor. The bottom wire will be connected to the 5V supply, other PINs are connected to the Analog PIN of Arduino.
A closed loop will be created when the wires come in touch with the water, the voltage received on the Arduino Analog pin will be converted to a corresponding digital value. This way we can detect the presents of water.
These are two copper wires which are dipped into the Sump Water Tank. And Analog pin present on the Arduino Nano will be used to sense the presence of water same like for the Overhead tank sensors.
Arduino will control the Water pump using the Internal relay. The relay present on the circuit can be used to start up to 1 HP single phase Water pump without starters.
This is also the used for the same purpose, you can use this section to replace the internal relay with any relay which is operating in 5V DC to get better power rating for driving the Water pump.
This is used for notification purpose. Buzzer will notify you with different type of beep sounds on different conditions such as:
Sump Tank Empty
Pump Dry run notification Alarm
Pump turn ON notification
Pump tuned OFF notification
Now let’s move to the components required to build this project. You can buy all these components from third party vendors like E-bay, Amazon etc. Purchase links are there in the description.
Arduino Nano……….. Amazon.com / Amazon.in
16*2 LCD Display........Amazon.com / Amazon.in
5V Relay......................Amazon.com / Amazon.in
Piezo Buzzer...............Amazon.com / Amazon.in
Push Button................Amazon.com / Amazon.in
LED.............................Amazon.com / Amazon.in
BC 547 Transistor.......Amazon.com / Amazon.in
IN4007 Diode..............Amazon.com / Amazon.in
220 Ω Resistor.............Amazon.com / Amazon.in
Trimpot 10K Ω Variable Resistor....Amazon.com / Amazon.in
10K Ω Resistor(6 pcs)...Amazon.com / Amazon.in
1K Ω Resistor................Amazon.com / Amazon.in
3P PCB Screw Terminal Block Connector......Amazon.com / Amazon.in
Female Pin Header Connector Strip.......Amazon.com / Amazon.in
Male Pin Header Connector Strip.......Amazon.com / Amazon.in
5V relay board(optional).......Amazon.com / Amazon.in
Jumper wire.......Amazon.com / Amazon.in
Wire Sensor...... Amazon.in
Here is the circuit diagram for our design, if anyone want to implement this project without using a PCB then please refer this diagram.
Now let’s have look into the PCB designing process. So first, you need to design your PCB. You can choose online or offline platform for designing your PCBs.
Here we used Fritzing software to design the PCB.
Once we finish the design, we will generate the Gerber file needed for manufacturing the PCB.
Then we ordered the PCB from JLCPCB which are also the sponsor of this project.
JLCPCB is a manufacture of high quality PBCs which are used in many industries for prototyping as well as in DIY projects.
Once you have your PCB design ready, simply upload the Geber file.
Review your PCB in the Gerber viewer
Select the property that you want and order your PCB at a reasonable price. If it is your first order from JLCPCB you can get up to 5 PCBs for only $2
Now let's try to solder the components. Try to solder the small components first and then proceed with the big one while soldering the components to the PCB. This will make the soldering process easier.
Follow the same procedure to complete the soldering process for rest of the components.
Now we can upload the sketch to our Arduino. Connect Arduino to your computer using the USB cable and upload the code shown here.
#include <LiquidCrystal.h>
const int SpmpSensorPin = A0; // set A0 as the Spump water sensor pin
int SpmpsensorValue = 0; // variable to store the value coming from the sensor
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;// define the Arduino pins used to connect with the LCD pins RS, EN, D4 to D7
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);//initialize the library by associating any needed LCD interface pinwith the arduino pin number it is connected to
#define EXTRELAYPIN 13 // Arduino pin tied to vin pin of the External Relay Circuit
#define RELAYPIN 8 // Arduino pin tied to Relaypin of the Relay Circuit
#define BUZZER 9 // Arduino pin tied to +ve terminal of the Buzzer
#include <EEPROM.h>
int flag = 0;
int flag1 = 1;
const int level_25 = A1, level_50 = A2, level_75 = A3, level_100 = A4;
String percentage = "<0" ;
int resist = 100;
int k=1,z=1;
byte Level0[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111
};
byte Level1[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111
};
byte Level2[8] = {
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte Level3[8] = {
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte NoLevel[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
byte tank[8] = {
0b10001,
0b10001,
0b10001,
0b11111,
0b11111,
0b11111,
0b11111,
0b00000
};
byte arrow[8] = {
0b00000,
0b00100,
0b00110,
0b11111,
0b11111,
0b00110,
0b00100,
0b00000
};
void setup() {
Serial.begin(9600);
lcd.createChar(0, Level0);
lcd.createChar(1, Level1);
lcd.createChar(2, Level2);
lcd.createChar(3, Level3);
lcd.createChar(4, NoLevel);
lcd.createChar(5, tank);
lcd.createChar(6, arrow);
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
pinMode(RELAYPIN, OUTPUT); // Relay pin as output pin
pinMode(EXTRELAYPIN, OUTPUT); // Relay pin as output pin
digitalWrite(RELAYPIN, LOW); //Turn off the relay
digitalWrite(EXTRELAYPIN, HIGH); //Turn off the relay
pinMode(BUZZER, OUTPUT); // Buzzer pin as output pin
digitalWrite(BUZZER, LOW); //Turn off the Buzzer
pinMode(level_25, INPUT); // Buzzer pin as output pin
pinMode(level_50, INPUT); // Buzzer pin as output pin
pinMode(level_75, INPUT); // Buzzer pin as output pin
pinMode(level_100, INPUT); // Buzzer pin as output pin
lcd.print("Automatic Water");
lcd.setCursor(0, 1);
lcd.print("*Pumping System*");
delay(1000);
delay(5000);
lcd.clear();
digitalWrite(BUZZER, HIGH);
delay(250);
digitalWrite(BUZZER, LOW);
}
void loop() {
while (1) {
Serial.println(analogRead(SpmpSensorPin));
if (analogRead(SpmpSensorPin) <= 100 && flag == 0) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("*SumTank Empty*");
lcd.setCursor(0, 1);
digitalWrite(RELAYPIN, LOW);
digitalWrite(EXTRELAYPIN, HIGH);
lcd.print("*Pump kept OFF*");
digitalWrite(BUZZER, HIGH);
delay(1000);
digitalWrite(BUZZER, LOW);
delay(2000);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("LOW");
lcd.setCursor(12, 1);
lcd.print("HIGH");
water_level();
delay(2000);
lcd.clear();
} else if (analogRead(SpmpSensorPin) > 100) {
Serial.println(flag);
lcd.setCursor(0, 1);
lcd.print("LOW");
lcd.setCursor(12, 1);
lcd.print("HIGH");
water_level();
if (flag == 0) {
lcd.setCursor(0, 0);
lcd.print("PMP ON ");
digitalWrite(RELAYPIN, HIGH);
digitalWrite(EXTRELAYPIN, LOW);
k++;
if(k>=200){
k=1;
delay(10);
digitalWrite(BUZZER, HIGH);
delay(10);
digitalWrite(BUZZER, LOW);
}
} else if (flag == 1) {
delay(1000);
digitalWrite(RELAYPIN, LOW);
digitalWrite(EXTRELAYPIN, HIGH);
lcd.setCursor(0, 0);
lcd.print("PMP OFF ");
lcd.setCursor(12, 0);
lcd.print(percentage + "% ");
if(z==1){
z=0;
digitalWrite(BUZZER, HIGH);
delay(250);
digitalWrite(BUZZER, LOW);
delay(250);
digitalWrite(BUZZER, HIGH);
delay(250);
digitalWrite(BUZZER, LOW);
delay(250);
digitalWrite(BUZZER, HIGH);
delay(250);
digitalWrite(BUZZER, LOW);
}
}
}
}
}
void water_level() {
int a = analogRead(level_100);
int b = analogRead(level_75);
int c = analogRead(level_50);
int d = analogRead(level_25);
Serial.println();
if (a > resist) {
lcd.setCursor(9, 1);
lcd.write(byte(3));
lcd.setCursor(10, 1);
lcd.write(byte(3));
int i;
flag = 1;
percentage = "100";
} else {
lcd.setCursor(9, 1);
lcd.write(byte(4));
lcd.setCursor(10, 1);
lcd.write(byte(4));
percentage = "75";
}
if (b > resist) {
flag1 = 2;
lcd.setCursor(7, 1);
lcd.write(byte(2));
lcd.setCursor(8, 1);
lcd.write(byte(2));
} else {
lcd.setCursor(7, 1);
lcd.write(byte(4));
lcd.setCursor(8, 1);
lcd.write(byte(4));
percentage = "50";
}
if (c > resist)
{
lcd.setCursor(5, 1);
lcd.write(byte(1));
lcd.setCursor(6, 1);
lcd.write(byte(1));
flag1 = 2;
} else {
lcd.setCursor(5, 1);
lcd.write(byte(4));
lcd.setCursor(6, 1);
lcd.write(byte(4));
percentage = "25";
flag = 0;
z=1;
}
if (d > resist)
{
lcd.setCursor(3, 1);
lcd.write(byte(0));
lcd.setCursor(4, 1);
lcd.write(byte(0));
} else {
lcd.setCursor(3, 1);
lcd.write(byte(0));
lcd.setCursor(4, 1);
lcd.write(byte(0));
int i;
flag = 0;
z=1;
delay(250);
k=k+82;
percentage = "EMTY";
lcd.setCursor(3, 1);
lcd.write(byte(4));
lcd.setCursor(4, 1);
lcd.write(byte(4));
delay(250);
digitalWrite(BUZZER, HIGH);
delay(10);
digitalWrite(BUZZER, LOW);
}
lcd.setCursor(10, 0);
lcd.write(byte(5));
lcd.setCursor(11, 0);
lcd.write(byte(6));
lcd.setCursor(12, 0);
lcd.write(byte(4));
lcd.write(byte(4));
lcd.write(byte(4));
lcd.write(byte(4));
lcd.setCursor(12, 0);
lcd.print(percentage + "%");
}
We have added comments in the program for better understanding of each codes. We have also added links to watch Arduino IDE installation for Windows and Ubuntu in the description. This will help you to understand more about Arduino if you are using it for the First time.
We are going to assemble the project as shown in this diagram.Please refer the sequence shown in this video while assembling the components together.
For the demo purpose we are using a 12V DC water pump. This circuit can support up to 1 HP Single phase water pump if you wish to use this circuit for Application level.
If you wish you can also connect a 5V relay having better current rating on to this circuit.
We will go through all the possible scenarios while testing our project. Let’s see the working first, then we will test all the possible scenarios one by one.
So, our project is working as per our design.
We hope that you have enjoyed the Project. And we would like to thank you once again for watching this video.
Please do not forget to subscribe to our YouTube channel if you like this video.