Water Net
1756 34
Subhabrata Basu

Water Net

India has 16% of the world's population and only 4% of the world's water resources at its...

Description:-

India has 16% of the world's population and only 4% of the world's water resources at its disposal. The situation is made worse by the fact that 70% of its water is contaminated. As a result, India ranks 120 among 122 countries on the Water Quality Index released by Water Aid. In India every year, 580,937,500,000 Litres of water is being wasted by TANK OVERFLOW (Overhead Tank & Reservoir Tank), which is more than 30% of total water wasted in India. I aim to solve this problem by proper management of the water and by preventing water wastage due to tank overflow. Saving Water is our Responsibility. So, Automate Your Responsibility. Proper Management of Water: Limiting the quantity of water supplied to each household depending on the number of members in that household. Monitoring the quantity of water spent by every household every day. Automating the water pump to stop tank overflow (Overhead Tank & Reservoir Tank). By these above 3 key water management strategies I aim to solve the water wastage problem. My device includes all these above-mentioned features and is well capable of preventing water wastage problem which happens due to tank overflow. Implementation: To implement the 3 features that I have previously mentioned in my project I am using a solenoid valve and a water flow meter to Limit the quantity of water supplied to each household. This solenoid valve and water flow meter will be in the inlet of the reservoir tank. When the water flow meter indicates that the required amount of water is supplied to a particular house then the solenoid valve will stop the water flow to the reservoir tank. I am using another water flow meter which will be in the outlet of the overhead tank to monitor the quantity of water spent by every household every day. Now, to automate the water pumps I am using 4 float switches 2 in the reservoir and 2 in the overhead tank to measure the water levels (higher and lower level) of both of these tanks to stop water overflow by starting and stopping the water pump. Let's understand this by an example, suppose a particular house has a water storage capacity of 500Lts(250Lts. Reservoir+ 250Lts overhead tank)., but the water supplied to the house is 700Lts. Now, when the reservoir is full the water pump will start and the overhead tank will start filling up, and when the overhead is also full then the solenoid valve will stop the water flow to the reservoir tank. Higher and Lower levels of water will be detected by float switches. Now the extra 200Lts. of water is saved by that user which will reflect in the Mobile Application. All these measurements and automation of the pump will be controlled by a single microcontroller which is ESP32. This ESP32 will send the water usage data to the cloud database through the internet. A user (house) will have a Mobile Application where he/she can monitor the daily water usage and water saved by them. A user also can apply for extra water for any occasion in his/her house through this mobile app. As this system creates a network and a database of water usage data, So I call it WATER NET. Application: The application of this system is obvious, saving the wasted water by stopping the water overflow. The problem of water shortage is not only the problem of India anymore, it is also the problem of our world. As this system will not only stop the water overflow it will also collect the daily water usage data of every house. This data will help policymakers and the water supply board to make necessary and important decisions regarding the water supply. Govt. bodies can use this system to manage water supply properly and start saving water. A single homeowner can also use this system to automate their responsibility of saving water.

Hardware Image

Project Used Hardware

ESP 32 (Wroom32), Water Flow Sensor (SAIER-> HZ21WA) , Float Switch, Sugar cube Relay (JIH JIK-> JQC-3FC(T73)DC12V) , Power Relay (Elecfuture-> EF93-12) , Relay Jack, Transistor (BC547), LM7805, Red LED (5 m.m.), Green LED (5 m.m.), Blue LED (5 m.m.), Common cathode RGB LED (5 m.m.) , 5 m.m. LED holder, THT Resistor (100 ohm/ 0.25 watt) , Solenoid Valve (1/2 inch, 230volt) , SMPS socket & Jack, Speaker terminal connector, Cable gland (PG7) , 16 Amp AC socket, Relimate connectors, Push Switches, Heat Shrink Tubes (2.5 m.m., 6 m.m.) , Vero Board (Dotted) , PVC box (10” x 8”) , 230/12 volt, 500mA Transformer, Diode 1N4007, Electrolytic Capacitors (1000uF, 25 volt) , Nut bolts, 1.5 Sq. m.m. 3 Core Cable with plug, 1.5 inch PVC Endcap

Project Used Software

Arduino IDE, Google Firebase, Easy EDA, Kodular

Project Hardware Software Selection

Hardware Selection: As an enclosure of this system, I have used a 10” x 8” PVC box. I used a dotted Vero board to solder all the components except the relay. Because the relay is not vero friendly, so I stick the relays with some tissue tape. A relay jack is used to power up the relay which will drive the water pump and the sugar cube relay will drive the solenoid valve. For connecting the solenoid valve to the box I have used an SMPS socket and jack on the right side of the box. ESP32 is the core controller of the whole system. I have chosen this board over NodeMCU because it has more GPIOs and processing power which I can use later on for more improvement. There are two (2) push switches to manually operate the water pump in case of any emergency. LED holder is used to hold all the LEDs on the top panel. For connecting the wire of the float switches & flow sensors I have used two (2) speaker terminals on the left side of the box. All the connectors, relay, and LEDs are connected to the circuit using relimate connectors. In this circuit, some resistors are used for the current limiting purpose of the transistor base and LEDs. Some diodes are also used for the relay and the bridge rectifier. For powering up the whole system a 230/12-volt step-down transformer is used with a bridge rectifier, filter, and some voltage regulators. 230 volt, 50 Hz A.C. is provided to the system through a 1.5 sq. m.m. 3 core cable. I used a cable gland PG7 for putting the cable inside of the box. A 16 amps 3pin socket is present to connect the water pump to the box. ESP32 is capable of connecting to the internet through wifi. But getting the wifi in every household is not possible, so I used an LTE router that has a sim card in it and provides a hotspot network. I soldered some wire from the LTE router ‘Network indication LED’ and connect it to an RGB LED which is mounted on the top panel. LED indicators: Power LED – RED Network LED – RGB Pump Status – GREEN Reservoir Status – BLUE Software Selection: I used an Arduino IDE to program the ESP32 board. I used it because it is very user-friendly and has a vast library collection for almost all the hardware devices and software systems. For the cloud service, I have used Google firebase because it is easy to use and comes with a free plan. It can be integrated with any mobile application. I have used the RTDB of the google firebase for storing & fetching the data. For making the schematics I have used Easy EDA. Easy EDA has a huge library collection of components and the LCSC component library is also connected with it. So, it is very convenient to choose the components from there. In this project, I have made an android application using Kodular. Kodular is an online platform where people can make android apps by visual programming and it is absolutely free. Here are two apps, one for the user and another for the Admin. User Application: A user has to log in to their account and has to connect the WaterNet device by scanning the QR code which is present in the bottom right corner of the device. Users are able to see the data of water consumption for the current time and their average weekly and monthly usage also. The status of the Reservoir Overhead tank and the water pump can be visualized by the application. Every user has a water limit level, so if any user needs extra water then they can apply for extra water. Admin Application: Admin has to log in by providing the proper credentials. Admin can view any of the user data like Device ID, User name, per day water limit. Admin can also approve the application for extra water depending upon their criteria and policies.

Circuit Diagram

Schematic
The water flow sensors are supplied with a 3.3 volt supply. The pulse/ output pin of the first flow sensor is connected to pin D12 and the second flow sensor's pulse/ output pin is connected to pin D13 of the ESP32. The float switch has 4 wires one is connected to Gnd and another is connected to a digital pin. All the digital pin connected to the float switches is internally pulled up. 4 float switches are connected to pin D15, D18, D1 & D21 of ESP32. Relays are driven by the ESP32 with the help of BC547 transistors. To limit the base current of the transistors 100-ohm resistor is used. Solenoid relays transistor base pin is connected to D22 & water pump relays transistor base pin is connected to D23. The reservoir empty led is connected to the D4 pin of the ESP32. 7805 regulates the voltage to 5 volts for supplying the ESP32.

Code

#if defined(ESP32)
#include <WiFi.h>
#include <FirebaseESP32.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
#endif
#include <addons/TokenHelper.h>
#include <addons/RTDBHelper.h>

#include <NTPClient.h>
#include <WiFiUdp.h>


#define WIFI_SSID "HOTSPOT_NAME"
#define WIFI_PASSWORD "SECRET_PASSWORD"
#define API_KEY "SECERET_API_KEY"
#define DATABASE_URL "FIREBASE_RTDB_URL"

FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "in.pool.ntp.org");

const int th=21,tl=19,rh=18,rl=15;
const int f1=12,f2=13;
const int wp =23, sv =22, re =4;
int X1,X2, Y1,Y2, TIME1,TIME2, FREQUENCY1,FREQUENCY2, WATER1,WATER2, LS1,LS2;
int prevHour, RL, OHL;
int ths,tls,rhs,rls;
int svs,wps;
float Total1, Total2, WL;

unsigned long pm,cm;

unsigned long epochTime;

void setup()
{

  Serial.begin(115200);
  pinMode(th,INPUT_PULLUP); pinMode(tl,INPUT_PULLUP); pinMode(rh,INPUT_PULLUP); pinMode(rl,INPUT_PULLUP);
  pinMode(f1,INPUT);pinMode(f2,INPUT);
  pinMode(wp,OUTPUT); pinMode(sv,OUTPUT); pinMode(re,OUTPUT);
  digitalWrite(wp,0); digitalWrite(sv,0); digitalWrite(re,0);
 
  delay(1000);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);

  config.api_key = API_KEY;
  config.database_url = DATABASE_URL;


  Firebase.begin(DATABASE_URL, API_KEY);
  Firebase.setDoubleDigits(5);
 
  timeClient.begin();
  timeClient.setTimeOffset(19800);
 
}

void loop()
{

  timeClient.update();
  epochTime = timeClient.getEpochTime();

  struct tm *ptm = gmtime ((time_t *)&epochTime);
 
  int monthDay = ptm->tm_mday;
  int currentMonth = ptm->tm_mon+1;
  int currentYear = ptm->tm_year+1900;
  int currentHour = timeClient.getHours();
  int currentMinute = timeClient.getMinutes();
  int currentSecond = timeClient.getSeconds();

  rhs = digitalRead(rh);
  rls = digitalRead(rl);
  ths = digitalRead(th);
  tls = digitalRead(tl);
 
  X1 = pulseIn(f1, HIGH);
  Y1 = pulseIn(f1, LOW);
  TIME1 = X1 + Y1;
  FREQUENCY1 = 1000000/TIME1;
  WATER1 = FREQUENCY1/7.5;
  LS1 = WATER1/60;
  if(FREQUENCY1 >= 0){
  Total1 = Total1+LS1;}

  X2 = pulseIn(f2, HIGH);
  Y2 = pulseIn(f2, LOW);
  TIME1 = X2 + Y2;
  FREQUENCY2 = 1000000/TIME2;
  WATER2 = FREQUENCY2/7.5;
  LS2 = WATER2/60;
  if(FREQUENCY2 >= 0){
  Total2 = Total2+LS2;}
 
  if (Firebase.ready() && ((currentHour-prevHour) == 4))
  {
    Firebase.setFloat(fbdo, "/WN-DV1-27/UW", Total2);
  }

  if(Total1>= WL || (ths == 0 && rhs == 0))
   { svs=0; }
  if( (currentHour == 06 && currentMinute == 00) || (currentHour == 12 && currentMinute == 00) || (currentHour == 16 && currentMinute == 00))
   { svs=1; }
  if( ((Total1 < WL) && (rhs == 0) && (ths == 1))  || ((tls == 0) && (rls == 1)) )
   { wps = 1;}
  if(ths == 0 || rls == 0)
   { wps = 0;}
  if (rls == 0)
   { digitalWrite(re,1); }
  else
   { digitalWrite(re,0); }

  digitalWrite(sv,svs);
  digitalWrite(wp,wps);

  if(rls == 0) { RL = 0; }
  if(rls == 1 && rhs == 1) { RL = 1; }
  if(rhs == 0) { RL = 2; }

  if(tls == 0) { OHL = 0; }
  if(tls == 1 && ths == 1) { OHL = 1; }
  if(ths == 0) { OHL = 2; }

   cm= millis();
   
  if (Firebase.ready() && cm-pm>= 1500)
   {
    Firebase.setInt(fbdo, "/WN-DV1-27/SV", svs);
    Firebase.setInt(fbdo, "/WN-DV1-27/WP", wps);
    Firebase.setInt(fbdo, "/GX-D1-01/TL", RL);
    Firebase.setInt(fbdo, "/GX-D1-01/OHL", OHL);
    Firebase.setFloat(fbdo, "/GX-D1-01/SW", Total1);

    Serial.printf("Get int a--  %s\n", Firebase.getFloat(fbdo, "/GX-D1-01/WL") ? String(fbdo.to<int>()).c_str() : fbdo.errorReason().c_str());
     WL=fbdo.to<int>();
 pm= millis();
     
   }  
}