ESP8266 based Automatic Water Level Controller for Pump

Published  February 28, 2022   0
Wireless Water Water Level Controller for Pump using NodeMCU

People in India have access to limited resources of water that is not all the time sufficient for countrymen. Availability of safe and clean drinking water to all the citizens is one of the major issues in our country due to the limited availability of natural resources as well as manmade activities. The main factors that contribute to this issue include poor management of available water resources and human negligence in water conservation leading to its wastage. One of the major reasons for water scarcities is that we are neither conscious enough regarding water conservation nor do we pay attention to stop the minor waste of water such as in day-to-day pumping of water in our houses. Motor Pump set is commonly used to store water in overhead tanks for daily usage in almost all the houses across the country. In the majority of cases, the pumps are not stopped until the water gets out of the tank and overflow is visible. Assuming minimum wastage of water to be 5 liters from one house in a day, it sums up to 150 liters every month and 1825 liters every year per house. Summing up for the entire nation, it results in a gigantic number. This project solves the issue of water wastage that is needed for the day.

Previously, we have worked on some water conservation projects,

Size of Target Beneficiary Group and Level of Acceptance of Innovation:

The solution developed here covers almost all the people in the country who use the pumping systems for household water storage purposes. The size of the market for the product is extensive. In India, it is intended to cover almost 10 million families. From a broader perspective, this solution can be developed for industrial applications as well. Being simple in fabrication and easy to install and use, this product is likely to be accepted and adopted by even the common public of the country. Our aim is “Save water, save life”. As per IS: 1172-1993 average water consumption of a person in a day is about 200 liters. This results in annual consumption of 73000 liters by one person in India. Comparing the above two facts if the solution provided here (Wireless Intelligent Water Conservator) is adopted; it will result in saving of 182.5 billion liters of water annually in India. This saving of water will reduce dependency on rainfall to some extent and if we calculate on a mass ground, with this much saving of water, we will cater to the need of 2.5 million people nationally per annum.

Component Requirement for Wireless Intelligent Water Conservator

Project Used Hardware

  • ESP8266,
  • Relay Module,
  • Transistors

Project Used Software

  • Arduino IDE

Project Hardware Software Selection

I use two ESP8266 for Wireless Data transfer. One ESP8266 is working as a Master. Another one as a client(slave). HTTP Client & Webserver protocol is used for easy wireless data transfer. Relays are switches that open and close circuits electro-mechanically or electronically. Relays control one electrical circuit by opening and closing contacts in another circuit. Transistors are used for Water sense.

Circuit Diagram

 

Wireless Water Conservator using NodeMCU Circuit Diagram

At any instant of time, if the water in the overhead tank is below the minimum required level, it will trigger on the water pump automatically. Similarly, when water crosses the specified upper level in the overhead water tank, the water pump is turned OFF. This intelligence of the control circuit results in the saving of water to a great extent.

Code
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
const char* ssid ="nitesh";
const char* password ="11223344";
IPAddress ip(10,10,10,55); 
IPAddress gateway(10,10,10,1); 
IPAddress subnet(255,255,255,0);
String message = "10101010";
ESP8266WebServer server(80);
void handleRoot() {
   server.send(200, "text/html", message); 
}
void setup() {
   server.on("/", handleRoot);
  server.begin();
    Serial.begin(115200);
    delay(500);
    WiFi.config(ip,gateway,subnet);
    for(uint8_t t = 4; t > 0; t--) {
        Serial.printf("[SETUP] WAIT ...\n", t);
        Serial.flush();
        delay(1000);
    }
      WiFi.mode(WIFI_STA);
      WiFi.disconnect(true);
    WiFi.begin(ssid,password);
    if(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    Serial.println("Connected");
  }
 pinMode(D2,INPUT);
 pinMode(D1,INPUT);  
}
void loop() {
  int a,b;
   a = digitalRead(D1); //lower level
   b = digitalRead(D2); //upper level
    int l;
    if(a==0 && b==0){l=0;}
    if(a==1 && b==1){l=1;}
    if(a==0 && b==1){l=0;}
    static int k=l;
    if(a==0 && b==0 && k==0){
      k=1;
      }
    if(a==0 && b==1 && k==1){
      k=1;
      }
    if(a==1 && b==1 && k==1){
      k=0;
      }  
  server.handleClient();
    // wait for WiFi connection
    if((WiFi.status() == WL_CONNECTED)) {
        HTTPClient http;
        if(k == 1)
        {  
           http.begin("http://10.10.10.1/motoron");//HTTP
          Serial.print("10.10.10.1/motoron");
          int httpCode = http.GET();
           http.end();
        } 
        else if(k == 0)
        {
          http.begin("http://10.10.10.1/motoroff");
          Serial.println("10.10.10.1/motoroff");
          int httpCode= http.GET();
          http.end();
        } 
    }
}

.........................................................................

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
const char* password = "11223344";
int max_connection = 8;
IPAddress staticIP(10,10,10,1); // IP address from Admin pannel
IPAddress gateway(10,10,10,1);
IPAddress subnet(255,255,255,0);
int httpCode;
HTTPClient http;
ESP8266WebServer server(80); //Server on port 80
void motoron() {
  server.send(200, "text/plain", "motor on" );
  Serial.println("motor on");
  digitalWrite(D1, LOW);               
}
void motoroff() {
  server.send(200, "text/plain", "motor off" );             
  Serial.println("motor off");
  digitalWrite(D1, HIGH);;               
}
void setup(void){
  Serial.begin(115200);
  Serial.println("");
  WiFi.mode(WIFI_AP);           
  WiFi.softAP(ssid, password, 1, false, max_connection);
  WiFi.softAPConfig(staticIP, gateway, subnet);
  Serial.printf("Stations connected to soft-AP = %d\n", WiFi.softAPgetStationNum());
  IPAddress myIP = WiFi.softAPIP(); //Get IP address
  Serial.print("HotSpt IP:");
  Serial.println(myIP);
   pinMode(D1, OUTPUT);
   delay(1000);
   server.on("/", handleRoot);
   server.on("/motoron", motoron);
   server.on("/motoroff", motoroff);
   server.begin();                 
   Serial.println("HTTP server started");
}
void loop(void){
      server.handleClient();         
}

Video

Have any question realated to this Article?

Ask Our Community Members