Water Quality Monitoring System Using IoT and Machine Learning
Water Quality Monitoring System Using IoT and Machine Learning
Machine Learning
Nikhil Kumar Koditala Dr.Purnendu Shekar Pandey
Computer Science and Engineering Computer Science and Engineering
BML Munjal University BML Munjal University
Gurugram, India Gurugram, India
nikhil.koditala.15cse@bml.edu.in purnendu.pandey@bml.edu.in
Abstract—World Economic Forum ranked drinking water services. PowerBI which is also a Microsoft platform is used
crisis as one of the global risk, due to which around 200 to display the sensor values in the form of Web page. This
children are dying per day. Drinking unsafe water alone causes paper also uses MQTT client broker architecture to transmit
around 3.4 million deaths per year. Despite the advancements in
technology, sufficient quality measures are not present to measure data from micro controller to external MQTT broker service.
the quality of drinking water. By focusing on the above issue, Turbidity measures the large number of suspended particles
this paper proposes a low cost water quality monitoring system in water that is invisible. Higher the turbidity higher the
using emerging technologies such as IoT, Machine Learning and risk of diarrhea, cholera. Lower the turbidity then the water
Cloud Computing which can replace traditional way of quality is clean. besides turbidity, pH is also an important measure
monitoring. This helps in saving people of rural areas from
various dangerous diseases such as fluorosis, bone deformities etc. which measures the acidic level of drinking water. Temperature
The proposed model also has a capacity to control temperature sensor measures how the water is, hot or cold.
of water and adjusts it so as to suit environment temperature. Other part of this paper is to sense the external temperature
Based on our model we have achieved R-squared score of 0.933. near the water storage and control heater or cooler respectively
depending on temperature. This part of paper uses machine
Index Terms—Water quality monitoring, Internet of Things,
Machine learning, Cloud Computing, MQTT, Rural Development
learning, where the system predicts the weather conditions
using previous labeled dataset and controls heater and cooler
according to external weather conditions. This makes the sys-
tem completely automated without any manual interventions.
I. I NTRODUCTION
Whenever the value of turbidity reaches predefined threshold
Nowadays, Due to limited water resources and increasing an email alert will be sent to concerned authorities informing
population water has become a vital resource for mankind. the situation, forcing them to take immediate action.
Clean and safe drinking water is the most important resource
for mankind. As most of the diseases these days spread II. L ITERATURE R EVIEW
through water there is a need for online real time water quality Pradeepkumar M, Monisha J, Pravenisha R, Praiselin V,
monitoring system. The methods used for water quality assess- Suganya Devi K entitled ”The Real Time Monitoring of Water
ment at present involve collection of random samples of water Quality in IoT Environment”. This paper discusses not only
at various locations weekly or monthly and analyzing them in sensor based system but also it introduces cloud computing
the laboratories. This approach is not much efficient because architecture into IoT which makes the sensor data accessible
they have various drawbacks such as long time consump- worldwide.
tion, only water samples from few areas can be determined Atif A, Wasai Shadab, Mohammad Hassan, Shamim, Alelaiwi
simultaneously. This method also involves manual work to and Anwar Hossain entitled ”A Survey on Sensor-Cloud: Ar-
monitor the quality of water regularly. Theses methods are also chitecture, Applications, and Approaches” discusses about the
costly and are not capable enough in large populated countries sensor-cloud infrastructure, approaches, and different layers of
like India, China. In order to overcome these drawbacks we transferring generated data by connecting sensors with cloud
need a real time system which monitors water quality through services.
sensors such as pH, turbidity and temperature and updates Nikhil Kedia entitled ”Water Quality Monitoring for Rural
those values in Cloud service. This system consists of sensors Areas-A Sensor Cloud Based Economical Project” This paper
which measure the chemical composition of water. These not only highlights embedded sensor systems, but also dis-
sensor values are then passed to NodeMCU micro controller cusses the challenges and economic viability of the system
which has inbuilt WiFi module, using which the data is passed involving Mobile Network Operator and Government. This
over to Azure Event Hub. From Event Hub data is stored in system directly contacts Government to take action based on
Azure Storage hub in the form of structured data. the severity of quality issue.
Thereafter using Stream hub data is streamed to external R.Karthik Kumar, M.Chandra Mohan, S.Vengateshapandiyan,
A. Adjusting Temperature
Algorithm. 1 demonstrates the temperature control module
of the system. External temperature is calculated from ge-
tExternal() function, which is explained in detail at machine
learning section. We also calculate the temperature of water
using DS18B20 waterproof temperature sensor. If the external
temperature is hot i.e. greater than 25 ◦C and water tempera-
ture is hot( >15 ◦C) then cooler gets turned ON and heater gets
turned OFF. Similarly in cold climates the second if statement
controls the temperature.
B. Sending Email
Algorithm. 2 explains the email module of the system. Tur-
Fig. 1. IoT Architecture bidity is calculated from getTurbidity() function and whenever
the turbidity is greater than 4.0, the system sends the email to
Result: Water temperature adjusted according to TABLE I
Environment M ONTHLY AVERAGE OF N EW D ELHI , I NDIA
External temperature = getExternal();
Year Month New Delhi
Temperature = getTemperature(); 1931 1 15.4
if Externaltemperature > 25 then 1931 2 15.2
if temperature > 15 then 1931 3 21.2
1931 4 29.7
heater = OFF; 1931 5 33.1
cooler = ON;
end
end module, we designate the vector as coef and as intercept.
if Externaltemperature < 10 then
if temperature < 15 then y(w, x) = w0 x0 + w1 x1 + ....wn xn
heater = ON;
cooler = OFF;
end According to our dataset, sklearn linear regression module
end predicted coef as [-0.00056244 , 0.19589288] and intercept as
Algorithm 1: Algorithm for adjusting temperature 24.80431407431011. So, our equation to predict temperature
is as follows:
y(year, month) = 24.80431407431011 + year(-0.00056244) +
concerned authorities. At the same time it also keeps a check month(0.19589288)
on count so that the authorities are not flooded with emails
continuously. VI. E XPERIMENT A ND S IMULATION S ETUP
As this paper involves various technologies such as IoT,
Result: Sending email to authorities machine learning and cloud computing it requires a large
turbidity = getTurbidity(); hardware and software pipe lining. This section explains the
count = Threshold limit; hardware and software setup of the model.
if turbidity > 4.0 then
if count > 0 then A. Block Diagram
sendEmail(); Fig 2 explains the complete structure of the project in
count = count - 1; the form of a block diagram. The block diagram consists
end of temperature sensor, turbidity sensor, external temperature
polluted = true; sensor, NodeMCU microcontroller, power supply, Azure cloud
end platform and a webapp built through powerBI. Azure cloud
Algorithm 2: Algorithm for sending Email to authorities platform has 3 sub blocks, Event hub, Storage unit and Stream
hub. The event hub acts as a first line of interface between the
sensors and azure cloud. Event hub then transfers the data to
V. M ACHINE L EARNING storage unit of azure. Then we use stream hub to export the
Providing temperature controlled water is also important data to powerBI.
besides quality, in areas near the equator due to extreme B. Hardware and Software Components
climatic conditions. This model uses machine learning to
predict temperature of environment near the water storage Different hardware and software components used in this
system. paper are listed below: