IoT Water Quality Monitoring System
IoT Water Quality Monitoring System
ii
Acknowledgement
We express our special thanks and gratitude to Prof. Ramesh Chand
Kashyap of the Department of Electronics & Communication Engineering
(ECE) for her able guidance and valuable support in completing our project.
Heartfelt thanks are also conveyed to all the members of the teaching and non-
teaching staff of the Department of ECE for their cordial support and help,
whenever needed.
Date:
…………………
Santanu Singha Mahapatra
.…………………
Kankana Chandra
……………………
Manisha Kumari
……………………
Nayanika Biswas
2
Contents: Page
No.
1. Abstract...................................................................................................4
2. Introduction.............................................................................................5-6
3. Literature Review....................................................................................7
4. Components
Description…………………………………………………….
5. Methodology
1. Problem Definition......................................................................9
2. Planning and Approach.................................................................10-11
3. Design Issues...............................................................................12
4. Block Diagram
5. Circuit Diagram
6. Algorithm……………………………………………………….
7. Pseudo code
6. Measurements, Results and Discussion (for hardware proj.) .13-
18 Simulation, Results and Discussion (for software proj.).....................19-20
7. Conclusion and Scope of future work........................................................21
8. References.................................................................................................22
9. Annexure…………………………………………………........
3
3. ABSTRACT
Water is a vital resource for life, and it is essential to monitor its quality to ensure public
health and environmental sustainability. Traditional methods of water quality monitoring
involve collecting water samples and analyzing them in a laboratory, which can be time-
consuming and expensive. Therefore, there is a need for a real-time water quality
monitoring system that can provide continuous data on various water quality parameters.
This project focuses on a water quality monitoring system project that uses sensors such
as DHT11, gas sensor, temperature sensor, turbidity sensor, pH sensor, and water flow
sensor. The project aims to develop a comprehensive system for monitoring water
quality parameters in real-time. A multidisciplinary team of scientists, engineers, and
software developers collaborates to design and implement a system that can collect and
process water quality data from various sources. In the data analysis stage, water quality
data is analyzed using statistical models and machine learning algorithms that can detect
patterns and anomalies in the data, identifying trends and correlations between water
quality parameters and environmental factors. The models must generate alerts when
water quality parameters exceed safe levels.
The water quality monitoring system project using sensors has several benefits. Firstly,
it can provide real-time data that can inform decision-making regarding water
management and resource allocation. Secondly, it can identify pollution sources and
enable prompt action to be taken to prevent waterborne illnesses and environmental
damage. Thirdly, it can enhance public awareness and education regarding water. In
conclusion, the water quality monitoring system project using sensors can improve water
management, protect public health, and sustainably manage water resources.
4
4. INTRODUCTION
Water is an essential resource for life, and its quality is crucial for ensuring public
health and environmental sustainability. Water quality monitoring is an essential
part of managing water resources, and it involves collecting and analyzing data on
various water quality parameters. These parameters include pH, temperature,
dissolved oxygen, turbidity, and nutrient levels, among others. Traditional water
quality monitoring methods have several limitations, including cost, time lags, and
the labor-intensive nature of sampling. Therefore, there is a need for a real-time
water quality monitoring system to overcome these limitations and ensure the
safety and health of human populations and ecosystems.
A water quality monitoring system project using sensors such as DHT11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor is a project
that aims to develop a comprehensive system for monitoring water quality
parameters in real-time. This project involves a multidisciplinary team of scientists,
engineers, and software developers who collaborate to design and implement a
system that can collect and process water quality data from various sources.
The DHT11 sensor is a digital temperature and humidity sensor that can measure
temperature and humidity levels in the surrounding environment. This sensor is ideal
for measuring temperature and humidity levels in water, which is critical for
monitoring the growth of harmful bacteria and algae. The gas sensor is another
essential sensor that can detect the presence of harmful gases in the water, such as
carbon monoxide and hydrogen sulfide. These gases can indicate the presence of
pollution, and their detection can help to prevent waterborne illnesses and
environmental damage.
Temperature sensors are used to measure the temperature of the water. Temperature
is a critical parameter that affects the solubility of dissolved gases and the metabolic
rates of aquatic organisms. The turbidity sensor measures the clarity of the water and
detects the presence of suspended solids. High turbidity levels can indicate the
presence of pollutants, such as sediment and organic matter, which can have
detrimental effects on aquatic ecosystems.
The pH sensor measures the acidity or alkalinity of the water. Changes in pH can
affect the chemical reactions and biological processes in aquatic ecosystems. High or
low pH levels can be harmful to aquatic organisms, including fish and other aquatic
life. The water flow sensor measures the flow rate of the water. The flow rate is an
important parameter that can affect the distribution of nutrients and pollutants in
water resources.
The water quality monitoring system project using sensors involves a four-stage
process: sensor development, data acquisition, data processing, and data analysis. In
the sensor development stage, the sensors are selected and calibrated to measure
specific water quality parameters accurately. The sensors must be robust and
accurate and able to operate under different environmental conditions.
In the data acquisition stage, the monitoring equipment is installed in various water
sources, such as rivers, lakes, and reservoirs. The equipment must be able to collect
water quality data continuously and transmit it to a central database in real-time. The
1
equipment must also be robust and able to operate under different environmental
conditions, such as extreme temperatures and weather events.
In the data processing stage, the water quality data collected from the sensors is
processed using software algorithms that can clean, transform, and store data in a
central database. The software must be able to integrate data from different sources,
such as sensors, weather stations, and other environmental data, and handle large
volumes of data in real-time.
In the data analysis stage, the water quality data is
analyzed using statistical models and machine
learning algorithms that can detect patterns and
PC with anomalies in the data. The models must be able to
ThinkSpeak Server identify trends and correlations between water
quality parameters and environmental factors,
such as weather, land use, and population density.
The models must also be able to generate alerts
when water quality parameters exceed safe levels.
2
4. Objectives
The primary goal of our proposed project is to assist aquafarmers in
measuring water quality parameters in real-time using IoT and cloud
technology. Our pro- posed project is centered on an automated
system that measures and displays the dissolved oxygen level,
turbidity, temperature, and pH value of water on a website. The
designed device can be placed in the ponds and tanks where these
aquatic species are raised by farmers. To monitor the water quality
metrics, we will use a TDS sensor, pH sensor, and dissolved oxygen
meter. All of these sensors are connected to a microcontroller called
an Arduino UNO WiFi.
The sensor data is recorded and saved in the cloud, and data visualization in the
form of a time series charts and histograms is displayed alongside the sen- sor
reading on the website. The sensor data is first sent to the ThingSpeak IoT
platform, an open-source IoT analytics platform that assists both beginners and
experts in getting started with basic IoT-based projects. Following the trans-
mission of data to the ThingSpeak platform.
5. LITERATURE REVIEW
Water quality monitoring is crucial in ensuring the safety of drinking water and the
protection of aquatic ecosystems. Traditional methods of water quality monitoring,
such as collecting water samples and analyzing them in a laboratory, can be time-
consuming and expensive. Real-time water quality monitoring systems that use
sensors have gained popularity in recent years due to their ability to provide
continuous data on various water quality parameters. In this literature review, we will
discuss the different types of sensors used in water quality monitoring systems and
their applications. Temperature sensors are essential in water quality monitoring
systems as they measure the temperature of the water, which affects the solubility of
dissolved gases and the metabolic rates of aquatic organisms. Several temperature
sensors are available in the market, including thermistors, resistance temperature
detectors, and thermocouples. In a study by Liu et al. (2019), temperature sensors
were used to monitor the temperature of a drinking water distribution network. The
study found that temperature fluctuations could cause bacterial growth, which could
affect the quality of the drinking water. Turbidity sensors measure the clarity of the
water and detect the presence of suspended solids, which can indicate the presence of
pollutants. Several turbidity sensors are available in the market, including optical
sensors, nephelometers, and absorption sensors. In a study by Christensen et al.
3
(2019), turbidity sensors were used to monitor the water quality of a small stream.
The study found that turbidity levels could vary depending on the time of day and the
weather conditions, indicating the importance of continuous monitoring. pH sensors
measure the acidity or alkalinity of the water, which can affect chemical reactions
and biological processes in aquatic ecosystems. Several pH sensors are available in
the market, including glass electrodes, ISFET sensors, and litmus paper. In a study
by Song et al. (2017), pH sensors were used to monitor the water quality of a river.
The study found that changes in pH levels could affect the survival of aquatic
organisms. Water flow sensors measure the flow rate of the water, affecting the
distribution of nutrients and pollutants in water resources. Several water flow sensors
are available in the market, including magnetic, vortex, and ultrasonic flow sensors.
In a study by Li et al. (2020), water flow sensors were used to monitor the flow rate
of a river. The study found that changes in the flow rate could affect the
concentration of pollutants in the water. Gas sensors detect the presence of harmful
gases in the water, such as carbon monoxide and hydrogen sulfide, indicating the
presence of pollution. Several gas sensors are available in the market, including
electrochemical sensors, optical sensors, and thermal conductivity sensors. In a study
by Zhang et al. (2019), gas sensors were used to monitor the water quality of a river.
The study found that the concentration of dissolved oxygen could affect the
production of greenhouse gases in the water. DHT11 sensors are digital temperature
and humidity sensors that can measure temperature and humidity levels in the
surrounding environment. In a study by Islam et al. (2021), DHT11 sensors were
used to monitor the water quality of a river. The study found that changes in
temperature and humidity levels could affect the survival of aquatic organisms. In
conclusion, water quality monitoring systems that use sensors have several benefits,
including providing real-time data, identifying pollution sources, and enhancing
public awareness and education regarding water. The type of sensor used in a water
quality monitoring system depends on the specific water quality parameter being
measured and the environmental conditions under which the sensor will operate.
Therefore, careful consideration of the type of sensor used in a water quality
monitoring system is essential to ensure accurate and reliable data collection.
4
6. HARDWARE IMPLEMENTATION
PH SENSOR:
The pH sensor measures the acidity or alkalinity of the water. Changes in pH can
affect the chemical reactions and biological processes in aquatic ecosystems. High or
low pH levels can be harmful to aquatic organisms, including fish and other aquatic
life
The pH sensor estimates the activity of hydrogen particles in liquids. It has two
probes bronze and silver with different diameter having difference between probes as
1.2cm. It is based on the principle that an interface of two liquids generates the
potential difference which can be recorded. In this event the Atlantis Highlights in
Computer Sciences, volume 4 124 convergence of hydrogen particles inside the
aqueous solution is not the same that results the potential difference on glass
electrode and calomel reference electrode. The pH level of drinking water should be
between the range of 6.5 - 8.5.
5
Fig 1: pH Sensor
voltage 5 V.
Measuring range 0∼14 pH.
Operating temperature 0∼60 ℃.
Accuracy 0.1 pH (25 ℃).
Response time less than 1 min.
Pin Connections
pH sensor Module Pins
Pins
Signal/ A AO
- GND
+ 5V
TURBIDITY SENSOR:
6
Fig2: Turbidity Sensor
Specifications of SEN0044
Pin Connections
TDS sensor Pins Pins
Signal/ A A1
- GND
+ 5V
Temperature sensors are used to measure the temperature of the water. Temperature
is a critical parameter that affects the solubility of dissolved gases and the metabolic
rates of aquatic organisms. The turbidity sensor measures the clarity of the water and
detects the presence of suspended solids. High turbidity levels can indicate the
presence of pollutants, such as sediment and organic matter, which can have
detrimental effects on aquatic ecosystems.
7
having power supply range from 3 V to 5.5 V [33-35]. The operating temperature
range is -55˚ to +125˚ C with accuracy of +/-0.5˚C.
SPECIFICATIONS
8
PARAMETERS VALUES
voltage 3∼5 V
Accuracy ±0.5°C.
9
PIN CONNCECTION
Red Wire 5V
Yellow Wire 2
FLOW SENSOR:
The water flow sensor measures the flow rate of the water. The flow rate is an
important parameter that can affect the distribution of nutrients and pollutants in
water resources.
The water management can be done through water flow sensor YF-S201 model of ½
inch is used for exaggerated utilization of water in localities at consumer end. This
sensor has 3 pin for interfacing with ESP32. Two pins for biasing as 5V VCC and
Gnd. It consists of water rotor and hall-effect sensor when rotor rotates water flow
through it and the speed alters according to rate of flow. The hall-effect sensor
outputs the pulse signal. The output is in pulse which communicated with ESP32 and
send signal to relay to cut the water supply through phone by admin. This is easy and
cost effective approach to maintain water consumption.
10
Fig 4: Flow Sensor
GAS SENSOR:
The gas sensor is another essential sensor that can detect the presence of harmful
gases in the water, such as carbon monoxide and hydrogen sulfide. These gases can
indicate the presence of pollution, and their detection can help to prevent waterborne
illnesses and environmental damage.
ESP32 MICROCONTROLLER :
ESP32 is a System on Chip (SoC) microcontroller that has gained prominence in the
Internet of Things (IoT) space. ESP32 is a better and more powerful microcontroller
board than Arduino. ESP32 has inbuilt dual Wi-Fi and Bluetooth support. It has full
TCP/IP support for full stack internet connection. Thanks to its Wi-Fi module it can
act as an access point as well as a Wi-Fi station
11
Fig7: ESP32 microcontroller
LCD DISPLAY:
The whole design of the system is based mainly on IOT which is a newly introduced
concept in the world of development. There are basically two parts included, the first
one is hardware & second one is software. The hardware part has sensors which help
to measure the real time values, another one is arduino atmega328 converts the
analog values to digital one, & LCD shows the displays output from sensors, Wi-Fi
module gives the connection between hardware and software. In software we
developed a program based on embedded c language. The PCB is designed at first
level of construction and has components and sensors mounted on it. The BLYNK
app is installed in the android version to see the output. When the system gets started
dc current given to the kit and arduino and WIFI gets on. The parameters of water are
tested one but one and their result is given to the LCD display. The app provided
with hotspot gives the exact value as on LCD display shows on the kit. Thus like this
when the kit is located on any specific water body and WIFI is provided we can
observe its real time value on our android phone anywhere at any time
SOFTWARE IMPLEMENTATION
12
1. Programming Arduino using Arduino IDE.
13
Flowchart of the system.
14
Programming Arduino Using Arduino IDE
The Arduino microcontroller can be programmed using the
Arduino IDE, which supports a wide range of microcontrollers,
including the ESP32, MKR1000, Ar- duino Uno, an Arduino
Mega, and Arduino Nano. IDE (Interpreter Developed
Environment) is a term coined by Arduino.cc. This is open-
source software that supports almost all Arduino modules and is
simple to install. The IDE environ- ment is made up of two
parts: an editor and a compiler. The editor is used to write the
required code, while the compiler is used to compile and upload
the code to the Arduino Module. Both C and C++ are supported
in this environment [21].
15
our system design. Therefore, we installed the Wi-Fi NINA
library to connect the microcontroller to the internet, as well as
the required sensor libraries for the pH sensor, TDS meter, and
dissolved oxygen sensor. The libraries required to write the
data to the cloud database have been included. We started
writing the code after
16
successfully installing all of the libraries and modules, and the
next steps were compilation and error checking. If any issues are
discovered in the code, they will be displayed in the error
console at the bottom of the editor. We uploaded our code to the
microcontroller because it was error-free. By visiting the Tools
tab and picking the port option, we verified the Arduino model
and port number of our microcontroller linked to the computer
before uploading.Figure 4.11 shows the Arduino IDE.
17
microcontrollers is easier. In the free version of ThingSpeak, a
user will have access to over 8 channel fields which represent
the reading from the sensor. This means one can send up to
eight sensors data to ThingSpeak at a time.
18
ThingSpeak was chosen as the cloud platform for our system.
We downloaded the Arduino ThingSpeak library and selected
multiple write example code before sending the data to
ThingSpeak. We were able to send numerous sensor readings to
the cloud using the multiple write code. We have added the
working code of our system’s sensors in this write multiple code
example. Then we compiled the code and checked for errors, as
well as the transmission delay, which should be at least 15
seconds in the free version, with shorter delays available only to
ThingSpeak premium subscribers.
We connected the microprocessor to Wi-Fi after compiling
the code by in- putting the SSID and password of our router in
the code. Then we created a channel in ThingSpeak with our
project name. A channel with a unique id has been created.
Then, we generated the Write API key for the ThingSpeak
channel and updated it in the code. This Write API key enabled
us to transmit data from Arduino to ThingSpeak. As indicated in
the figure, channel number and Write API keys can be
discovered in the dashboard and they can be accessed by
selecting the API keys tab.
19
we have added widgets for these fields and data visualizations in
the form of time series charts are also added. Figure 4.13 shows
the illustration regarding adding widgets and time charts.
ThingSpeak also provides MATLAB Analysis and
Visualizations.
20
Picture illustrating how to add widgets and data visualization.
21
22
Quality Range of parameter by WHO [20] and EU standards
7. METHODOLOGY
The water quality monitoring system project using sensors dht11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor involves
collecting data from various sensors to monitor different water quality parameters. In
this section, we will discuss the methodology used in this project.
Sensor Selection:
The first step in developing a water quality monitoring system is selecting the
appropriate sensors to measure different water quality parameters.
In this project, we have selected the following sensors:
1. DHT11 sensor: This sensor measures the temperature and humidity of the
environment and will be used to monitor the surrounding temperature and humidity
levels of the water.
2. Gas sensor: This sensor detects the presence of harmful gases in the water, such as
carbon monoxide and hydrogen sulfide. We will use this sensor to detect any pollution
in the water.
3. Temperature sensor: This sensor measures the temperature of the water, which
affects the solubility of dissolved gases and the metabolic rates of aquatic organisms.
4. Turbidity sensor: This sensor measures the clarity of the water and detects the
presence of suspended solids, which can indicate the presence of pollutants.
5. pH sensor: This sensor measures the acidity or alkalinity of the water, which can
affect chemical reactions and biological processes in aquatic ecosystems.
6. Water flow sensor: This sensor measures the flow rate of the water, affecting the
distribution of nutrients and pollutants in water resources.
23
Hardware Setup:
Once we have selected the sensors, the next step is to set up the hardware. We will use
an Arduino board to connect the sensors and collect data. The hardware setup for each
sensor is as follows:
1. DHT11 sensor: The DHT11 sensor will be connected to the digital pins of the
Arduino board.
2. Gas sensor: The gas sensor will be connected to the analog pins of the Arduino board.
3. Temperature sensor: The temperature sensor will be connected to the analog pins of
the Arduino board.
4. Turbidity sensor: The turbidity sensor will be connected to the analog pins of the
Arduino board.
5. pH sensor: The pH sensor will be connected to the analog pins of the Arduino board.
6. Water flow sensor: The water flow sensor will be connected to the digital pins of the
Arduino board.
Data Collection:
Once the hardware setup is complete, we can begin collecting data. The Arduino board
will be programmed to read data from each sensor and store it in a data logger. The data
logger can be an SD card module, which will store the data in a text file. Data Analysis:
The final step in this project is analyzing the data collected from the sensors. The data
will be analyzed using a software tool such as IoT platform (. The analysis will involve
the following steps:
1. Data cleaning: The data will be cleaned to remove any outliers or errors.
2. Data visualization: The data will be plotted on graphs and charts to visualize any
trends or patterns.
3. Data interpretation: The data will be interpreted to identify any changes or
anomalies in the water quality parameters.
4. Data reporting: A report will be generated to summarize the data collected and
provide recommendations for improving water quality. In conclusion, the methodology
for the water quality monitoring system project using sensors dht11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor involves selecting
appropriate sensors, setting up the hardware, collecting data, and analyzing the data
using software tools.
24
The problem addressed by the water quality monitoring system project using sensors
dht11, gas sensor, temperature sensor, turbidity sensor, pH sensor, and water flow sensor
is the lack of continuous monitoring of water quality parameters in many water
resources. Traditional water quality monitoring methods involve collecting water
samples at intervals and analyzing them in a laboratory. However, this approach is time-
consuming and expensive, and it cannot provide real-time monitoring of water quality
parameters.
Continuous monitoring of water quality parameters is essential to ensure the health and
safety of aquatic ecosystems and human populations that rely on them for drinking
water, recreation, and agriculture. The lack of continuous monitoring can lead to the
undetected pollution of water resources, which can have serious consequences for
human health and the environment. For example, pollution can cause the death of
aquatic organisms, the spread of waterborne diseases, and the degradation of water
quality.
The problem is particularly acute in developing countries, where access to clean water is
limited, and water resources are often polluted by industrial and agricultural activities. In
these countries, the lack of resources and infrastructure for water quality monitoring
makes it difficult to detect and address water pollution effectively.
The water quality monitoring system project using sensors dht11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor aims to address
this problem by providing a low-cost and easy-to-use solution for continuous monitoring
of water quality parameters. The system can be deployed in various water resources,
including rivers, lakes, and groundwater sources, and can provide real-time data on
water quality parameters. The system can also be used to detect pollution and other
environmental issues promptly, allowing for timely action to address them.
Water is an essential resource for all living beings, and its quality is of utmost
importance. Water quality monitoring is crucial in identifying and addressing the
contamination of water resources caused by natural or anthropogenic sources.
Traditional water quality monitoring methods are time-consuming, laborious, and costly.
They often fail to provide continuous monitoring, which is necessary for addressing the
pollution caused by various sources, including human activities.
The problem addressed by the water quality monitoring system project using sensors
dht11, gas sensor, temperature sensor, turbidity sensor, pH sensor, and water flow sensor
is the lack of reliable and continuous monitoring of water quality parameters. The
absence of real-time data on water quality parameters can lead to the undetected
pollution of water resources, which can have severe consequences on human health and
aquatic ecosystems.
25
In developing countries, where access to clean water is limited, and water resources are
often polluted by industrial and agricultural activities, the problem is more acute. The
lack of resources and infrastructure for water quality monitoring makes it challenging to
detect and address water pollution effectively. Furthermore, the lack of awareness
among the local population and authorities about the importance of water quality
monitoring aggravates the situation.
The traditional water quality monitoring methods involve collecting water samples at
intervals and analyzing them in a laboratory. The process is time-consuming and can be
inaccurate due to human errors. The results may also not reflect the actual water quality
conditions at the time of sampling, which can lead to a lack of timely action to address
the pollution.
The water quality monitoring system project using sensors dht11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor aims to address
the problems associated with traditional water quality monitoring methods. The system
provides a low-cost and easy-to-use solution for continuous monitoring of water quality
parameters. The system can be deployed in various water resources, including rivers,
lakes, and groundwater sources. It provides real-time data on water quality parameters,
including temperature, pH, turbidity, and water flow rate. The system can also detect
pollutants in water and alert the authorities, allowing for timely action to address the
issue.
Overall, the water quality monitoring system project using sensors dht11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor addresses the lack
of continuous and reliable monitoring of water quality parameters. The system provides
an affordable, easy-to-use, and real-time solution for monitoring water quality, which is
essential for protecting human health and aquatic ecosystems.
Designing a water quality monitoring system using sensors dht11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor involves several
design issues that need to be addressed. The first issue is selecting appropriate sensors
that can accurately measure the water quality parameters of interest. The sensors should
be sensitive, reliable, and suitable for the environment in which they will be deployed.
Another design issue is the selection of a microcontroller that can process the sensor
data and transmit it to a central monitoring system. The microcontroller should have the
necessary processing power, memory, and communication capabilities to handle the
sensor data and transmit it in real-time.
26
Power management is another crucial design issue. The monitoring system should be
energy-efficient, and the power source should be reliable and long-lasting. The system
should also have a backup power source to ensure uninterrupted monitoring in case of a
power outage.
Finally, the design of the monitoring system should be scalable and flexible to allow for
easy integration of additional sensors and expansion of the monitoring network. The
system should also be user-friendly, with a simple interface for data visualization and
analysis. Addressing these design issues is crucial to developing a water quality
monitoring system that is accurate, reliable, and easy to use.
27
7.4. Block Diagram:-
28
7.5. Circuit Diagram
29
7.6. Algorithm of the proposed system
The proposed system's entire algorithm is shown in Figure 2. Initially, the serial monitor
of Arduino is initialized with 115200 baud rate. Later the ESP Wi-Fi module and the
Thing Speak Server is also initialized. The four sensors are being connected and the
values are read into the sensors. The algorithm flow of the ultrasonic and DHT 11 sensor
flow is explained. The Ultrasonic sensor reads the digital value directly so it is
considered as the duration of time in seconds. With the help of the duration, distance is
calculated . The DHT 11 Sensor reads the analog values of temperature and humidity.
Later the same values are sent into the Thing Speak server and the same values are
updated in the Serial monitor.(1)Distance = (Duration) / 58.8
30
(OVERALL SYSTEM ALGORITHM)
ALGORITHM FOR
TURBIDITY SENSOR
31
32
33
7.7. Pseudo Code:-
Step1: Start
Step10: Stop
34
Real Time Circuit
35
SOURCE CODE FOR NODE MCU
//
pass:zxcv123
A #include
<WiFi.h>
#include
"ThingSpeak.
h"
#include
<Adafruit_BME280.
h> #include
<Adafruit_Sensor.h>
#include <DHT.h>
#define DHT_SENSOR_PIN 21 // ESP32 pin GIOP21 connected to DHT11
sensor #define DHT_SENSOR_TYPE DHT11
DHT dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE);
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // ESP32 pin GIOP2 connected to DallasTemperature
sensor OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#include
"MQ135.
h"
#include
<WiFi.h>
#include
<Wire.h>
int
air_
qual
ity;
floa
t
36
ph_
leve
l;
int
sensorPi
n = 15;
volatile
long
pulse;
//unsigned
long lastTime;
float volume;
WiFiClient client;
// Timer variables
unsigned long lastTime =
0; unsigned long
timerDelay = 30000;
37
float pressure = 87;
float ph_act;
void setup()
{
Serial.begin(115200); //Initialize serial
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client); // Initialize ThingSpeak
dht_sensor.begin();
sensors.begin();
pinMode(34,
INPUT);
pinMode(36,
INPUT); //tds
pinMode(39, INPUT);
//PH sensor
pinMode(sensorPin,
INPUT);
attachInterrupt(digitalPinToInterrupt(sensorPin), increase, RISING);
}
void loop()
{
if ((millis() - lastTime) > timerDelay)
{
// Connect or reconnect to WiFi
38
if (WiFi.status() != WL_CONNECTED)
{
Serial.print("Attempting to
connect"); while (WiFi.status()
!= WL_CONNECTED)
{
WiFi.begin(ssid,
password);
delay(5000);
}
Serial.println("\nConnected.");
}
39
float humi = dht_sensor.readHumidity();
// read temperature in Celsius
40
//-----------DS1820 temperature sensor-----------
41
//------------TDS value pin 36----------
int TDS_Value = analogRead(36);
float voltage = TDS_Value * (5.0 / 1024.0);
Serial.print ("TDS_Sensor
Output :"); Serial.print
(TDS_Value);
Serial.print
("TDS_voltage (V):");
Serial.print (voltage);
Serial.println();
delay(1000);
// TDS value
// ph
value for
(int i = 0; i <
10; i++)
{
buffer_arr[i] =
analogRead(SensorPin);
delay(30);
}
for (int i = 0; i < 9; i++)
{
for (int j = i + 1; j < 10; j++)
{
if (buffer_arr[i] > buffer_arr[j])
{
temp =
buffer_arr[i];
buffer_arr[i] =
buffer_arr[j];
buffer_arr[j] =
temp;
}
}
42
}
avgval = 0;
for (int i = 2;
i < 8; i++)
avgval +=
buffer_arr[i
];
float volt = (float)avgval * 3.3 / 4096.0 / 6;
//Serial.print("Voltage: ");
//Serial.println(volt);
ph_act = -5.70 * volt + calibration_value;
Serial.print(
"pH Val: ");
Serial.printl
n(ph_act);
delay(500);
// ph value
43
// water flow
value volume =
2.663 * pulse / 1000 * 30;
if (millis() -
lastTime > 2000)
{ pulse = 0;
lastTime = millis();
}
Serial.print(
volume);
Serial.println
(" L/m");
if (x == 200)
{
44
Serial.println("Channel update successful.");
}
else {
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
lastTime = millis();
}
}
ICACHE_RAM_ATTR void
increase() { pulse++;
}
The water quality monitoring system using sensors DHT11, gas sensor, temperature
sensor, turbidity sensor, pH sensor, and water flow sensor was successfully implemented
and tested. The system was able to accurately measure the water quality parameters in
real-time, and the data was transmitted to a central monitoring system for analysis.
The DHT11 sensor was used to measure the temperature and humidity of the water,
while the gas sensor was used to detect the presence of toxic gases in the water. The
turbidity sensor was used to measure the amount of suspended particles in the water,
while the pH sensor was used to determine the acidity or alkalinity of the water. The
water flow sensor was used to measure the flow rate of the water, which can affect the
accuracy of the other sensor readings.
The data collected by the sensors was analyzed using statistical techniques to identify
any trends or patterns in the water quality parameters. The results showed that the water
quality parameters varied significantly over time and across different locations. The
system was able to detect changes in water quality parameters, which could be used to
identify potential sources of contamination or other environmental problems.
Overall, the water quality monitoring system using sensors DHT11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor was able to
45
provide accurate and reliable data on water quality parameters in real-time. The system
could be used to monitor the water quality of various water sources, including rivers,
lakes, and drinking water systems, and could help to identify and prevent potential
environmental problems.
6. CONCLUSION
In conclusion, the water quality monitoring system using sensors DHT11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor has been
successfully implemented and tested. The system was able to accurately measure water
quality parameters in real-time, providing valuable information for monitoring and
managing water resources.
The system design addressed the problem of water quality monitoring by integrating
multiple sensors to measure various water quality parameters simultaneously. The data
collected by the sensors was analyzed using statistical techniques to identify trends and
patterns in water quality parameters. The results showed that the system could detect
changes in water quality parameters and help to identify potential sources of
contamination or other environmental problems.
46
The system was designed with practicality in mind, making it suitable for use in various
water sources, including rivers, lakes, and drinking water systems. The use of wireless
technology for data transmission made it possible to monitor water quality remotely,
making it easier to monitor multiple water sources at once.
However, the system also had some limitations. For example, the accuracy of the sensor
readings could be affected by environmental factors such as temperature and flow rate.
Therefore, careful consideration must be given to the installation location of the sensors.
There are several areas for potential future work to further improve the water quality
monitoring system using sensors DHT11, gas sensor, temperature sensor, turbidity
sensor, pH sensor, and water flow sensor.
Firstly, the accuracy of the sensor readings could be improved by using more advanced
and precise sensors. This would require a higher level of expertise in sensor technology
and data analysis to ensure the accuracy of the readings.
47
Secondly, the system could be enhanced by incorporating additional sensors to measure
other water quality parameters such as dissolved oxygen, conductivity, and total
dissolved solids. This would provide a more comprehensive picture of water quality and
help to identify any emerging issues.
Thirdly, the data analysis techniques used to process the sensor readings could be
improved by using machine learning algorithms. This would allow for more accurate
predictions of water quality trends and early detection of anomalies, improving the
efficiency and effectiveness of the system.
Fourthly, the system could be extended to include a warning and alert system to notify
users of potential water quality problems. This would require the integration of a user
interface to display real-time data and trigger alerts based on predefined thresholds.
Finally, the system could be scaled up to cover a larger area, such as a city or region, by
deploying multiple monitoring stations. This would require careful planning and
coordination to ensure the data collected is accurate and reliable.
In conclusion, the water quality monitoring system using sensors DHT11, gas sensor,
temperature sensor, turbidity sensor, pH sensor, and water flow sensor has the potential
to provide valuable information for monitoring and managing water resources. Further
improvements could be made to the system, such as incorporating additional sensors or
enhancing the data analysis techniques used to process the sensor readings. As water
resources become increasingly scarce and polluted, systems like this one can help to
ensure the sustainability of our water supply and protect human health and the
environment.
48
REFRENCES
1. Singh, R., Singh, D., & Singh, A. (2018). Smart water quality monitoring
system using IoT. In Proceedings of the 4th International Conference on
Frontiers of Intelligent Computing: Theory and Applications (FICTA) 2018
(pp. 691-697). Springer.
2. Jadhav, M. S., Jagtap, M. S., & Joshi, S. R. (2017). IoT based water quality
monitoring system using raspberry pi. In 2017 2nd IEEE International
Conference on Recent Trends in Electronics, Information & Communication
Technology (RTEICT) (pp. 1919-1921). IEEE.
3. Gao, J., Li, Y., Li, X., Li, Y., & Wang, H. (2019). Design and implementation
of water quality monitoring system based on the internet of things. Journal of
Physics: Conference Series, 1223(1), 012031.
4. Patil, S., & Singh, A. (2018). An efficient and cost effective system for water
quality monitoring using Internet of Things (IoT). In 2018 International
Conference on Advances in Computing, Communications and Informatics
(ICACCI) (pp. 2129-2134). IEEE.
5. Zhang, Q., & Gao, Y. (2018). Water quality monitoring system based on
internet of things. In 2018 5th International Conference on Systems and
Informatics (ICSAI) (pp. 1033-1037). IEEE.
49
50