You are on page 1of 35

A PROJECT REPORT ON

IOT Based Water Quality Control System submitted


to

Maulana Abul Kalam Azad University of Technology

In partial fulfilment of the academic requirements for the awards of final Semester project in
Bachelor of Technology in Electrical Engineering
2023
By

Student’s Name: Debasis Dutta University Roll No: 16901619006

Student’s Name: Neha Bar University Roll No: 16901619047

Student’s Name: Asif khan University Roll No: 16901619061

Student’s Name: Liza Roy University Roll No: 16901619005

Student’s Name: Kiron Dey University Roll No: 16901619051

Under the guidance of

Prof. Sandipan Misra


(Assistant Professor)
Department Of Electrical Engineering

Academy of Technology
Adisaptagram, Hoogly
Hooghly-712121, West Bengal
CERTIFICATE OF ORIGINALITY
This is to certify that the project entitled IOT Based Water Quality Control System submitted to
Maulana Abul Kalam Azad University of Technology in the partial fulfilment of seventh semester of
the B.TECH degree in ELECTRICAL ENGINEERING is original work carried out under my guidance
by..

Student’s Name: Debasis Dutta University Roll No: 16901619006

Student’s Name: Neha Bar University Roll No: 16901619047

Student’s Name: Asif khan University Roll No: 16901619061

Student’s Name: Liza Roy University Roll No: 16901619005

Student’s Name: Kiron Dey University Roll No: 16901619051

The matter embodied in this project is genuine work done by the student and has not been
submitted whether to this University or to any other University/Institute for the fulfilment of the
requirement of any course of study.

……………………………… ………………………………….
Signature of HOD Signature of the Guide
Department of Department of
Electrical Engineering Electrical Engineering
Academy of Technology Academy of Technology
Date….………………….
Date….………………….

pg. 2
ACKNOWLEDGEMENT
We express our great deal of thanks to our college for providing us an opportunity to improve our
skills by assigning us a project. Our special thanks to Prof. Sandipan Misra for guiding us for such a
project.

We are greatly thankful to Prof. Sandip Saha Chowdhury HOD, E.E, and all other faculty members
who have guided us thoroughly and have given important details about this project and helping us
in making it a success.

Student’s Signature

University Roll No

pg. 3
CONTENTS
Topics Page No.
1. Abstract 5
2. Introduction 6
3. Literature Survey 7-8
4. Introduction to IOT 9
5. Design Methodology 10
6. Flow Chart of the Project 11
7. Tools and Components Used 12
8. Components Description 13-18
9. Circuit Diagram 19
10. Hardware and Software Requirements 20
11. System Architecture 21
12. Programming Codes 22-29
13. Experiments Results 30
14. Market Survey & Cost Estimation 31
15. Advantages and Disadvantages 32
16. Future Scope and Future Enhancement 33
17. Conclusion 34
18.Bibliography 35

pg. 4
Abstract

Water pollution is one of the leading fears for the green globalization. In order to guarantee the
safe supply of the drinking water the quality needs to be monitor in real time. In this project we
present a design and development of a low-cost system for real time monitoring of the water
quality in IOT (internet of things). The system consist of numerous sensors is used to measuring
physical and chemical parameters of the water. The parameters such as temperature, PH,
turbidity, TDS of the water can be measured. The measured values from the sensors can be
processed by the core controller. The ESP32 can be used as a core controller. The sensor data can
be viewed on internet using WI-FI system. Thorough the Wi-Fi system, the sensor output data is
sent to the concern authority for further steps to improve the water quality.

The economical and effective system of water quality observation is the toughest implementation
of impure water. Drinking water could be terribly precious for all people as water utilities face
more challenges. These challenges arise due to high population, less water resources etc. So,
different methods are used to monitor in the real time water quality. To make sure that safe
distribution of water is done, it should be monitored in real time for new approach in IOT based
water quality has been projected. Real time water quality observation is monitored by data
acquisition, method and transmission with increase in the wireless device network technology in
internet of things. The measured values from the sensors are interfaced by microcontroller and
the processed values remotely to the core controller Xtensa dual-core (or single-core) 32-bit LX6
microprocessor with a WI-FI protocol. This projected water quality observation interfaces sensors
with quality observation with IOT setting. WQM selects parameters of water like temperature, pH
level, water level and CO2 by multiple different device nodes. This methodology sends the
information to the web server. The data updated at intervals within the server may be retrieved or
accessed from any place within the world.

pg. 5
Introduction

The most valuable resource for human is clean drinking water. Compromising with water quality
would lead to seriously affect the health condition of humans. These days drinking water utilities
are facing various challenges in real time due to limited water resources, global warming, growing
population and pollution. Hence, there is need of better methodologies for real time water quality
monitoring. Conventional method of water quality monitoring involves the manual collection of
the water at different areas and this water is tested in laboratory. This approach takes long time
and high cost. Although the current methodologies have so many drawbacks:

a) Laborious

b) Absence of water quality information in real time

c) Poor spatial coverage

d) Lack of controlling unit to control the flow of the water in pipeline for safe supply of the
drinking water.

The online water monitoring technologies have made a considerable progress for source water
surveillance and water plant operation. The use of their technologies having high cost associated
with installation and calibration of a large distributed array of monitoring sensors. The algorithm
proposed on the new technology must be suitable for particular area and for large system is not
suitable. By concentrating on the above issues, this paper designed and developed low cost system
for real time water quality monitoring and controlling using IoT. In our design, physical and
chemical parameters of the water are measured by physiochemical sensors. The sensed values are
processed by core controller. ESP32 is used as core controller for this design. The IoT module
access processed data from the core controller to internet. The sensed data can be observed in the
internet browser with special IoT account. Water flow in the pipeline is controlled depending on
quality of the water through IoT. In addition to that the controlling and monitoring is observed
through mobile by using Wi-Fi provided by IoT module.

pg. 6
Literature Survey

Nikhil Kedia entitled “Water Quality Monitoring for Rural Areas-A Sensor Cloud Based
Economical Project.” Published in 2015 1st International Conference on Next Generation
Computing Technologies (NGCT-2015) Dehradun, India. This paper highlights the entire water
quality monitoring methods, sensors, embedded design, and information dissipation procedure,
role of government, network operator and villagers in ensuring proper information dissipation. It
also explores the Sensor Cloud domain. While automatically improving the water quality is not
feasible at this point, efficient use of technology and economic practices can help improve water
quality and awareness among people.
Jayti Bhatt, Jignesh Patoliya entitled “Real Time Water Quality Monitoring System”. This paper
describes to ensure the safe supply of drinking water the quality should be monitored in real time
for that purpose new approach IOT (Internet of Things) based water quality monitoring has been
proposed. In this paper, we present the design of IOT based water quality monitoring system that
monitor the quality of water in real time. This system consists some sensors which measure the
water quality parameter such as pH, turbidity, conductivity, dissolved oxygen, temperature. The
measured values from the sensors are processed by microcontroller and these processed values
are transmitted remotely to the core controller that is raspberry pi using Zigbee protocol. Finally,
sensors data can view on internet browser application using cloud computing.

Michal Lom, OndrejPribyl, Miroslav Svitek entitled “Industry 4.0 as a Part of Smart Cities”. This
paper describes the conjunction of the Smart City Initiative and the concept of Industry 4.0. The
term smart city has been a phenomenon of the last years, which is very inflected especially since
2008 when the world was hit by the financial crisis. The main reasons for the emergence of the
Smart City Initiative are to create a sustainable model for cities and preserve quality of life of their
citizens. The topic of the smart city cannot be seen only as a technical discipline, but different
economic, humanitarian or legal aspects must be involved as well. In the concept of Industry 4.0,
the Internet of Things (IoT) shall be used for the development of so–called smart products.
Subcomponents of the product are equipped with their own intelligence. Added intelligence is
used both during the manufacturing of a product as well as during subsequent handling, up to
continuous monitoring of the product lifecycle (smart processes). Other important aspects of the
Industry 4.0 are Internet of Services (IoS), which includes especially intelligent transport and
logistics (smart mobility, smart logistics), as well as Internet of Energy (IoE), which determines how
the natural resources are used in proper way (electricity, water, oil, etc.). IoT, IoS, IoP and IoE can
be considered as an element that can create a connection of the Smart City Initiative and Industry
4.0 – Industry 4.0 can be seen as a part of smart cities.

Zhanwei Sun, Chi Harold Li, Chatschik Bisdikian, Joel W.Branch and Bo Yang entitled “QOI-Aware
Energy Management in Internet-of-Things Sensory Environments”. In this paper an efficient
energy management frame work to provide satisfactory QOI experience in IOT sensory
environments is studied. Contrary to past efforts, it is transparent and compatible to lower

pg. 7
protocols in use, and preserving energyefficiency in the long run without sacrificing any attained
QOI levels. Specifically, the new concept of QOIaware “sensor-to-task relevancy” to explicitly
consider the sensing capabilities offered by an sensor to the IOT sensory environments, and QOI
requirements required by a task. A novel concept of the “critical covering set” of any given task in
selecting the sensors to service a task over time. Energy management decision is made
dynamically at runtime, as the optimum for long-term traffic statistics under the constraint of the
service delay. Finally, an extensive case study based on utilizing the sensor networks to perform
water level monitoring is given to demonstrate the ideas and algorithms proposed in this paper,
and a simulation is made to show the performance of the proposed algorithms.
Sokratis Kartakis, Weiren Yu, Reza Akhavan, and Julie A. McCann entitled “Adaptive Edge Analytics
for Distributed Networked Control of Water Systems” This paper presents the burst detection
and localization scheme that combines lightweight compression and anomaly detection with graph
topology analytics for water distribution networks. We show that our approach not only
significantly reduces the amount of communications between sensor devices and the back-end
servers, but also can effectively localize water burst events by using the difference in the arrival
times of the vibration variations detected at sensor locations. Our results can save up to 90%
communications compared with traditional periodical reporting situations.

pg. 8
Introduction to IOT
In the past decade, all human life changed because of the internet. The internet of things has been
heralded as one of the major developments to be realized throughout the internet portfolio of
technologies. The Internet of Things (IOT) is concerned with interconnecting communicating
objects that are installed at different locations that are possibly distant from each other. Internet
of Things represents a concept in which, network devices have ability to collect and sense data
from the world, and then share that data across the internet where that data can be utilized and
processed for various purposes. The internet of things describes a vision where objects become
part of internet: where every object is uniquely identified and access to the network. IOT
communication is quite different from the traditional human to human communication, bringing a
large challenge to existing telecommunication and infrastructure. Furthermore, IOT provides
immediate information regarding access to physical objects with high efficiency. The concept of
Internet of Things is very much helpful to achieve real time monitoring of sensor data. Internet of
Things (IOT) is a kind of network technology, which is based on information sensing equipment’s
such as RFID, infrared sensors, GPS, laser scanners, gas sensors and so on, can make anything join
the Internet to exchange information, according to the protocol, which gives intelligent
identification, location and tracking, monitoring and management. In proposing system, we
introduce cloud computing technique for monitoring sensor values on the internet. Cloud
computing provides the access of applications as utilities, over the internet. The cloud computing
characteristic and development approaches are explained in. Cloud computing is a large-scale
processing unit which processes in run time and it is also a very low-cost technology based on the
IP. The application area of IOT includes building and home automation, smart city project, smart
manufacturing of various products, wearable’s, health care systems and devices, automotive etc.

pg. 9
Design Methodology

PROJECT DESIGN: -
In this, we present the theory on real time monitoring of water quality and quantity using IoT. The
system consists of Esp32 microcontroller, different type of sensors like water TDS, pH and turbidity
sensor and Temperature sensor. The ESP32 is the main processor of the system which control and
process the data generated by the sensors. Inbuild Wi-Fi module of ESP32 device which help to
transfer the data to the cloud over internet. TDS sensor helps to measure the conductivity of the
solution and estimates the TDS from that reading. This data will be sent to cloud for storage and
analysis purposes. The other sensor like temperature, pH and turbidity sensor measures the water
quality and help to determine whether the water is useful for drinking or any agricultural pur-
poses.
In the below mentioned picture, here is a prototype design of our project---

Fig 01:-Project Design

pg. 10
Flow Chart of the Project

Fig 02: Flow Chart of The Project


pg. 11
Tools and Components Used

COMPONENTS NAME COMPONENTS SPECIFICATION


1.Esp32 devkit v1 Operating voltage: - 3.3 volt
This board is used with 2.4 GHz dual-mode Wi-Fi and
Bluetooth chips by TSMC 40nm low power technology, power
and RF properties best, which is safe, and scalable to a variety
of applications
2. Ph sensor module Module Power: DC 9.00V 1Amp,
Measuring Range: 0-14PH
Output: Analogue value in the range of 0.5V to 3V
3. Turbidity Sensor  Working voltage: DC 5V
 Operating Current: 30mA (MAX)

4. TDS Sensor  Input Voltage: 3.3/5V


 Output Voltage: 0 ~ 2.3V
 Working Current: 3 ~ 6mA
 TDS Measurement Range: 0 ~ 1000ppm
 Power indication LED
 Analog Signal, easy to implement
 Waterproof TDS Probe
5.Temperature sensor (A35)  The sensitivity of LM35 is 10 mV/degree Celsius. As
temperature increases, output voltage also increases.
 It is a 3-terminal sensor used to measure surrounding
temperature ranging from -55 °C to 150 °C.
 It provides output voltage in Centigrade (Celsius) does
not require any external calibration circuitry.
6. I2C liquid crystal display  I2C Address: 0X20~0X27 (the original address is 0X27,
you can change it yourself)
 Supply voltage: 5V
7. SMPS for power supply  Input: 20-240Ac 50-60HZ
 Output: 9V -1AMP
8. LM7805 Regulator  A LM7805 Voltage Regulator is a voltage regulator that
outputs +5 volts.

9. Capacitor (104 AEC)  0.1µF

10. Zero PCB Board  Dimension: 8cm x 5cm


 Thickness: 1.5mm

Table no 1: - Tools and Components

pg. 12
Components Description

Sensor:-
A sensor is a device which is used to detect and response to some type of input from the physical
surroundings. The specific inputs are pressure, motion, heat, light, moisture or any other
environmental phenomenon. Generally, a signal may be produced as outcome which is changed to
readable display in the sensor locality or transmitted by machine over a set-up for analyzing the
signal for supplementary processing. The subsequent sensors are used in this research work.

ESP32:-
It is a series of low-cost, low-power system on a chip microcontroller with integrated Wi-Fi and
dual-mode Bluetooth. The ESP32 series employs a Tensilica Xtensa LX6 microprocessor in both
dual-core and single-core variations and includes built-in antenna switches, RF balun, power
amplifier, low-noise receive amplifier, filters, and power-management modules. ESP32 is created
and developed by Espressif Systems, a Shanghai-based Chinese company, and is manufactured by
TSMC using their 40 nm process. It is a successor to the ESP8266 microcontroller.

Fig 03: - Esp32 devkit v1

pH Sensor: -
The pH level in the water is an pointer to give an indication about the amount of hydrogen ions
forming in the certain quantity of water. An alkaline solution has less positively charged ions than
pg. 13
the acidic solution, so it has the ability to produce an electric current. Due to this action, the pH
meter might work as a voltmeter which measures the electric potential induced by the acidic
solution. The pH difference is measured by comparing the produced electric potential with the
known value and it is deducted.

Fig 04: - Ph sensor

Turbidity Sensor: -

The turbidity level of water is measured by turbidity sensor which used to detect the water quality
by measuring. It has the ability to detect the pendant particles in the water. This is done by
measuring the light transmittance and scattering rate; it leads for the changes in the amount of
total suspended solids (TSS) in water. If TSS increases which results increase in the liquid turbidity
level. It proves that clean water contains low turbidity.

Fig 05: - Turbidity Sensor

Temperature Sensor: -

pg. 14
LM35 is a temperature measuring device having an analog output voltage proportional to the
temperature. It provides output voltage in Centigrade (Celsius). It does not require any external
calibration circuitry. The sensitivity of LM35 is 10 mV/degree Celsius. As temperature increases,
output voltage also increases.
E.g., 250 mV means 25°C.
It is a 3-terminal sensor used to measure surrounding temperature ranging from -55 °C to 150 °C.
LM35 gives temperature output which is more precise than thermistor output.

Fig 06: - Temperature sensor

I2C liquid crystal display:-


This is an 16x2 LCD display screen with I2C interface. It is able to display 16x2 characters
on 2 lines, white characters on blue background. Usually, Arduino LCD display projects will
run out of pin resources easily, especially with Arduino Uno.

Fig 07: - I2C liquid crystal display

SMPS for power supply: -

pg. 15
A switched-mode power supply (SMPS) is an electronic circuit that converts power using switching
devices that are turned on and off at high frequencies, and storage components such as inductors
or capacitors to supply power when the switching device is in its non-conduction state.

Fig 08: - SMPS for power supply

LM7805 Regulator: -
A voltage regulator IC maintains the output voltage at a constant value. 7805 IC, a member of 78xx
series of fixed linear voltage regulators used to maintain such fluctuations, is a popular
voltage regulator integrated circuit (IC). The xx in 78xx indicates the output voltage it provides.

Fig 09: - LM7805 Regulator

Capacitor(104AEC): -

pg. 16
Here we used a capacitor of value of 0.1µF.

Fig 10: - Capacitor (104 AEC)

Zero PCB Board:-


Zero PCB is basically a general-purpose printed circuit board (PCB), also known as
perfboard or DOT PCB. It is a thin rigid copper sheet with holes pre-drilled at standard
intervals across a grid with 2.54mm (0.1-inch) spacing between holes. Each hole is
encircled by a round or square copper pad so that component lead can be inserted into the
hole and soldered around the pad without short-circuiting the nearby pads and other leads.
For connecting the lead of component with another lead, solder these together or join
these using a suitable conducting wire.

Fig 11: - Zero PCB Board

TDS:-
pg. 17
TDS Sensor detects the Total Dissolved Solids (TDS) levels in the water which can be
used to indicate the water quality. The Grove - TDS Sensor can be applied in water quality
applications such as TDS meter, well water, aquarium, hydroponics, etc.
It supports 3.3 / 5V input voltage and 0 ~ 2.3V Output Voltage making it easy to be
compatible with all Arduino, ESP Boards. The sensor also provides a waterproof probe,
making the testing process much easier to handle.

Fig 12: - TDS Sensor

Circuit Diagram
pg. 18
Fig 13:
-
Circuit
Design

pg. 19
Hardware and Software Requirements

HARDWARE REQUIREMENTS: -

1. MICROCONTROLLERS: - Esp32
2. Wi-Fi module: -Inbuild Esp32 Wi-Fi Module
3. Sensors: - Ph sensor, Turbidity sensor, Temperature Sensor, TDS Sensor
4. Regulator: -LM7805
5. Display: - I2C LCD
6. Power supply: - 9-volt, 1 amp
7. Others: - Zero PCB board, DC connector, Capacitor, Voltage- regulator

SOFTWARE REQUIREMENTS: -
Arduino IDE

System Architecture
pg. 20
The execution of the projected system is shown. It consists of pH, temperature, electric
conductivity (EC) and turbidity sensors. The sensor data are processed in the ESP32 module and
shifted by means of the Wi-Fi data transfer unit to the main server. The authorized users can
access this data by sorting their account using a User ID and password. The collected data is,
undergoing various stages such as process, analysis, transmit and finally display the data in real
time users. The Esp32 is a self-contained SOC Wi-Fi Module with integrated TCP/IP protocol stack.
It permits the microcontroller unit to right of entry to the Wi-Fi network. This low-cost Wi-Fi
microchip is manufactured by M/S Espruino. This Esp32 uses serial transmitter/receiver (Tx/Rx) for
sending and receiving the data in Ethernet buffers, and serial commands to uncertainty and
modify the configurations of the Wi-Fi module.

pg. 21
Fig 14: -System Architecture

Programming Codes

ESP32 Code: -
/*
* TDS 32
* Tur 34
* Temp 39 Vn
*/
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <Wire.h>
#include "LiquidCrystal_I2C.h"
#include <string>
#include "index.h" //Web page header file
#define TdsSensorPin 32
#define VREF 5.5 // analog reference voltage(Volt) of the ADC
#define SCOUNT 30 // sum of sample point
int analogBuffer[SCOUNT]; // store the analog value in the array, read from ADC
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0;
int copyIndex = 0;
float averageVoltage = 0;
float temperature = 25; // current temperature for compensation
WebServer server(80);
/*Put your SSID & Password*/
const char *ssid = "Redmi Note 7 Pro"; // Enter SSID here
const char *password = "12121212"; // Enter Password here
float tempC = 0;
int sensorPin = 34;
float volt;
float ntu;
float tdsValue;
String tds = "0";
String turbidity ="0";
String isDrinkable = "Yes";
// set the LCD number of columns and rows
int lcdColumns = 16;

pg. 22
int lcdRows = 2;
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
//Temperature LM35
#define ADC_VREF_mV 5000.0 // in millivolt
#define ADC_RESOLUTION 4096.0
//===============================================================
// This routine is executed when you open its IP in browser
//===============================================================
void handleRoot() {
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void handleTemp() {
// read the ADC value from the temperature sensor
int adcVal = analogRead(39);
// convert the ADC value to voltage in millivolt
float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION);
// convert the voltage to the temperature in °C
tempC = milliVolt / 10;
Serial.println(tempC);
// convert the °C to °F
float tempF = tempC * 9 / 5 + 32;

delay(10);
//server.send(200, "text/html", SendHTML(turbidity, tds, isDrinkable)); //Send ADC
value only to client ajax request
String t = (String)tempC;
lcd.setCursor(10,0);
lcd.print(t+"C");

server.send(200, "text/plane", t);


}

void handleTurbidity() {
volt = 0;
for(int i=0; i<800; i++)
{
volt += ((float)analogRead(sensorPin)/1023)*5;
}
volt = volt/800;
volt = round_to_dp(volt,1);
if(volt < 2.5){
ntu = 3000;
}else{
ntu = 1120.4*square(volt)+5742.3*volt-4353.8;
ntu = ntu/1000000;
}
turbidity = (String)ntu+" NTU";

pg. 23
delay(10);

//server.send(200, "text/html", SendHTML(turbidity, tds, isDrinkable)); //Send ADC


value only to client ajax request
server.send(200, "text/plane", turbidity);
}

void handleTds()
{
static unsigned long analogSampleTimepoint = millis();
if(millis()-analogSampleTimepoint > 40U){ //every 40 milliseconds,read the
analog value from the ADC
analogSampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(TdsSensorPin); //read the ana-
log value and store into the buffer
analogBufferIndex++;
if(analogBufferIndex == SCOUNT){
analogBufferIndex = 0;
}
}

static unsigned long printTimepoint = millis();


if(millis()-printTimepoint > 800U){
printTimepoint = millis();
for(copyIndex=0; copyIndex<SCOUNT; copyIndex++){
analogBufferTemp[copyIndex] = analogBuffer[copyIndex];

// read the analog value more stable by the median filtering algorithm, and
convert to voltage value
averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF /
4096.0;

//temperature compensation formula: fFinalResult(25^C) = fFinalResult(cur-


rent)/(1.0+0.02*(fTP-25.0));
float compensationCoefficient = 1.0+0.02*(temperature-25.0);
//temperature compensation
float compensationVoltage=averageVoltage/compensationCoefficient;

//convert voltage value to tds value


tdsValue=(133.42*compensationVoltage*compensationVoltage*compensationVoltage
- 255.86*compensationVoltage*compensationVoltage + 857.39*compensationVoltage)*0.5;

//Serial.print("voltage:");
//Serial.print(averageVoltage,2);
//Serial.print("V ");
Serial.print("TDS Value:");
Serial.print(tdsValue,0);

pg. 24
Serial.println("ppm");
}
}
tds = (String)tdsValue+" PPM";
// set cursor to first column, first row
lcd.setCursor(0, 0);
// print message
lcd.print(turbidity);
server.send(200, "text/plane", tds);
}

void handleIsDrinkable()
{
if(tdsValue>39 && tdsValue < 150) //TDS range select
isDrinkable = "Yes";
else
isDrinkable = "No";
lcd.setCursor(0,1);
lcd.print(tds);
server.send(200, "text/plane", isDrinkable);
}
//===============================================================
// Setup
//===============================================================
void setup(void){
Serial.begin(115200);
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();

Serial.println();
Serial.println("Booting Sketch...");
/*
//ESP32 As access point
WiFi.mode(WIFI_AP); //Access Point mode
WiFi.softAP(ssid, password);
*/
//ESP32 connects to your wifi -----------------------------------
WiFi.mode(WIFI_STA); //Connectto your wifi
WiFi.begin(ssid, password);

Serial.println("Connecting to ");
Serial.print(ssid);

//Wait for WiFi to connect


while(WiFi.waitForConnectResult() != WL_CONNECTED){
Serial.print(".");

pg. 25
}

//If connection successful show IP address in serial monitor


Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //IP address assigned to your ESP
//----------------------------------------------------------------

server.on("/", handleRoot); //This is display page


server.on("/readTurbidity", handleTurbidity);//To get update of handleTurbidity
Value only
server.on("/readTds", handleTds);//To get update of handleTurbidity Value only
server.on("/readIsDrinkable", handleIsDrinkable);//To get update of handleTurbid-
ity Value only
server.on("/readTemp", handleTemp);//To get update of handleTurbidity Value only

server.begin(); //Start server


Serial.println("HTTP server started");
lcd.setCursor(0, 0);
lcd.print("Got IP: ");

lcd.setCursor(0, 1);
lcd.print(WiFi.localIP());
delay(5000);
lcd.clear();
}
//===============================================================
// This routine is executed when you open its IP in browser
//===============================================================
void loop(void){
server.handleClient();
delay(1);
}

float round_to_dp( float in_value, int decimal_place )


{
float multiplier = powf( 10.0f, decimal_place );
in_value = roundf( in_value * multiplier ) / multiplier;
return in_value;
}

float square(float in)


{
return in*in;
}

pg. 26
// median filtering algorithm
int getMedianNum(int bArray[], int iFilterLen){
int bTab[iFilterLen];
for (byte i = 0; i<iFilterLen; i++)
bTab[i] = bArray[i];
int i, j, bTemp;
for (j = 0; j < iFilterLen - 1; j++) {
for (i = 0; i < iFilterLen - j - 1; i++) {
if (bTab[i] > bTab[i + 1]) {
bTemp = bTab[i];
bTab[i] = bTab[i + 1];
bTab[i + 1] = bTemp;
}
}
}
if ((iFilterLen & 1) > 0){
bTemp = bTab[(iFilterLen - 1) / 2];
}
else {
bTemp = (bTab[iFilterLen / 2] + bTab[iFilterLen / 2 - 1]) / 2;
}
return bTemp;
}

Webpage Code: -
const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/
all.min.css" />
<style>
.card {
background: yellow;
padding: 30px;
box-sizing: border-box;
color: #fff;
margin: 20px;
box-shadow: 0px 2px 18px -4px rgba(0, 0, 0, 0.75);
font-size: 60px;
font-weight: bold;
}
</style>
<body>
<div class="card">
<label style="color: yellow">IoT Based Water Quality Measurement</label
><br /><br />
pg. 27
<i class="fas fa-faucet-drip fa-4x"></i>&nbsp;<label style="color: black"
>Turbidity Value:
<span id="turbidity" style="color: white"></span></label
><br />
<i class="fas fa-tint fa-4x"></i>&nbsp;<label style="color: black"
>TDS Value: <span id="tds" style="color: white"></span></label
><br />
<i class="fa-solid fa-glass-water fa-4x"></i>&nbsp;<label
style="color: black"
>Is Drinkable:
<span id="isDrinkable" style="color: white"></span></label
><br />
</div>
<script>
setInterval(function () {
// Call a function repetatively with 2 Second interval
getTurbidity();
getTDS();
isDrinkable();
}, 1000); //2000mSeconds update rate

function getTurbidity() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("turbidity").innerHTML = this.responseText;
}
};
xhttp.open("GET", "readTurbidity", true);
xhttp.send();
}

function getTDS() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("tds").innerHTML = this.responseText;
}
};
xhttp.open("GET", "readTds", true);
xhttp.send();
}
function isDrinkable() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("isDrinkable").innerHTML =
this.responseText;

pg. 28
}
};
xhttp.open("GET", "readIsDrinkable", true);
xhttp.send();
}
</script>
</body>
</html>
)=====";

Experiments Results
Experimental Input:

pg. 29
Fig 15: - For Mineral Water Fig 16: - Reading for Mud Water

Experimental Output:

Fig 17: - Reading for Mineral Water Fig 18: - Reading for Mud Water

Market Survey & Cost Estimation

We ran a brief survey of the market, and gathered some information about the availability and
price of the parts that we used in our project and also the total combined system price in the
market. Here is the list of information stated below…..

Cost Estimation of the Project in Market:


By judging all the parameters and surveying all the components price and the total combined
system price in the market, we got the estimated price of market around Rs. 2500.00

pg. 30
Cost Estimation of this Project Made by us: -
By purchasing all the parts from different sources and collecting all the necessary components
including different Hardware and Software’s, we got the estimated cost of our project is around
Rs. 3000.00.

Advantages and Disadvantages

ADVANTAGES: -
• This project is more suitable to monitor water quality parameters in real time.
• To monitor data from various locations IOT environment is provided.
• No need to visit the location to monitor the water quality parameters.
• Use of PIC microcontroller reduces the price of system by great extent.
• Due to real time monitoring the water quality parameters are available whenever required which
can indicate any water contamination occurred.

DISADVANTAGES: -
• Accuracy of the measured value depends on the sensor used.
• Required internet connection for real time water quality parameters monitoring

pg. 31
Future Scope and Further Enhancement
Domestic water is intended for human consumption for drinking and cooking purposes. The
Bureau of Indian Standards (Central Ground Water Board, 2017) provides details about acceptable
limits of substances such as Aluminium, Ammonia, Iron, Zinc etc. Traditional water quality
measurement involves manual collection of water at various locations, storing the samples in
centralized location and subjecting the samples to laboratory analytical testing Such approaches
are not considered efficient due to the unavailability of real time water quality information,
delayed detection of contaminants and not cost-effective solution. Hence, the need for continuous
online water quality monitoring.

Pollution levels in sea:

pg. 32
Measuring levels of temperature, salinity, oxygen and nitrates give feedback for quality-sensing
system in seawater.

Chemical leakage detection in revisers:


Extreme pH or low DO (Digital Output) values -signal chemical spills due to sewage treatment
plant or supply pipe problem. The water quality monitoring is important for several applications
such as environment monitoring of pond and ecosystem, drinking water distribution and
measurement, contamination detection in drinking water.

Conclusion

Based on a study of existing water quality monitoring system and scenario of water we can say
that proposed system is more suitable to monitor water quality parameters in real time. The
proposed system introduces wireless sensor networking using several sensors to measure water
quality, microcontroller and FIREBASE module which make sensor network simple, low cost and
more efficiently. Furthermore, to monitor data from all over the word IOT environment is
provided using ESP32 for creating gateway and also, cloud computing technology is used to
monitor data on the internet. Moreover, to make system user-friendly web browser application is
there. Therefore, the system will be low cost, faster, more efficient, real time and user friendly.
Thus, we can fulfil aim and objective of the proposed system.

pg. 33
Bibliography

 Nazleeni Samiha Haron, Mohd Khuzaimi B Mahamad, Izzatdin Abdul Aziz, MazlinaMehat, “A
System Architecture for Water Quality Monitoring System Using Wired Sensors” .Computer and
Information Science Department, University Technology PETRONASBandarSeri Iskandar, 31750
Tronoh, Perak DarulRidzuan, 2008.
 Fiona Regan, Antóin Lawlor and Audrey McCarthy,"Smart Coast Project–Smart Water Quality
MonitoringSystem”, Environmental Protection Agency, SynthesisReport.July. 2009
 ZulhaniRasin and Mohd Rizal Abdullah, “Water Quality Monitoring System Using Zigbee Based
Wireless Sensor Network,” IJET-IJENS, vol. 9, no. 10, pp. 14-18, Dec.2009.
 AN Ning, AN Yu, “A Monitoring System ForWater Quality,” IEEE International Conference on
Electrical and Control Engineering, pp. 4615-4617, 2010.
 Qiao Tie-zhu, Song Le, “The Design of Multi-Parameter Online Monitoring System of Water
Quality Based onGPRS,” Education Ministry Key Lab of AdvancedTransducers and Intelligent
Control System, Taiyuan Technology University, Taiyuan, China. 2010.

pg. 34
 Dong He, Li-Xin Zhang, “The Water Quality MonitoringSystem Based on WSN”, Institute of
Mechanical and electronic information, China University of Geosciences (WuHan), WuHan,China,
pp. 3661-3664, 2012
 NazleeniSamihaHaron, Mohd Khuzaimi B Mahamad, Izzatdin Abdul Aziz, MazlinaMehat, “Remote
Water QualityMonitoringSystem using Wireless Sensors” Proceedings of the 8th WSEAS Int. Conf.
on Electronics, Hardware, Wireless and Optical Communications, pp.148- 154.
 Kulkarni Amruta M., Turkan Satish M., “Solar Powered Water Quality Monitoring system using
wireless Sensor Network”,Dept. of E&TC, P.R.E.C., Loni University ofPune,Loni (MH), India, 2013.
 Prof. Sachin S. patil, Prof. S. J. Patil, Prof. M. M. Raste “WATER POLUTANT MONITRING
 USING SENSOR NETWORKS” International Journal of Advanced Research in Electronics and
Communication Engineering, Volume.3. Issue.8. Aug-2014, pp 829-833
 Nikhilkedia entitled “water quality monitoring for Rural Areas-A sensor cloud based Economical
project.” Published in 2015 1st International Conference on Next generation computing
technologies( NGCT-2015) Dehradun, India.
 Jayti Bhatia, Jignesh Patoliya, IoT based water quality Monitoring system, IRFIC, 21 feb, 2016. “Real
time water quality monitoring system”.

pg. 35

You might also like