Detection of Water Quality using Machine Learning and IoT

DOI : 10.17577/IJERTV10IS110022

Download Full-Text PDF Cite this Publication

Text Only Version

Detection of Water Quality using Machine Learning and IoT

Manya Kakkar, Vansh Gupta, Jai Garg and Dr. Surender Dhiman §

Electronics and Communication Engineering Department,

Dr. Akhilesh Das Gupta Institute of Technology & Management, New Delhi, India

AbstractWater is one of the most crucial elements for the existence of life. Drinking-water safety and accessibility are pressing issues all over the world. Drinking water which is polluted with contagious agents, harmful chemicals, and other contaminants may pose health concerns. In this work, a method for analyzing water quality and warning users when water becomes polluted is presented. Water can be contaminated by a variety of factors. These factors are taken into consideration and utilised to forecast whenever its time to clean the water. The system makes use of IoT and Machine Learning technology. It consists of physical and chemical sensors that detect pH, Turbid- ity, Color, Dissolved Oxygen, Conductivity to check influencing factors.The data collected by the sensors is saved in a database and then submitted for analysis. The neural network method is used to forecast the outcome. It is employed in order to generate a non-linear connection for projected output. When any of the parameters falls below the standard values, the system sends an alarm notification to the user. This enables the user to be aware of water pollution in their home tanks ahead of time. This technology is not restricted to home tanks; it may also be applied in water treatment facilities and enterprises.

Index TermsInternet of Things, Machine Learning, Water Quality, WSN


    Over the years, one of the worlds primary concerns has been the protection and quality of water. Only 2% of the worlds water resources are fresh water supplies which are getting polluted as a result of human activity. Contaminated water is not only unpleasant to drink and look at, but also hazardous to ones health. According to World Health Organi- sation (WHO), consumption of contaminated water has caused 30 percent deaths worldwide. A regular check on the stored water from the storage tank might be the first step in preventing personal water contamination. This can assist to mitigate the negative impacts of contaminated water on humans. The study uses IoT to check water quality, compares anticipated outcomes with observed data using neural networks, and alerts the user if necessary. The data gathered from water quality monitoring systems can be used to a map of link between observed data and changes in quality measurements, which can then be used to forecast future water quality. The traditional technique of analysing water quality samples in a laboratory requires a lot of time, effort, and is sometimes inefficient also. Further , predicting water quality becomes increasingly

    difficult. In recent years, the growth of computer technologyhas spurred the earlier behaviors.


      The Internet of Things (IoT) is a sought-after technology that allows the user to connect eclectic sensors and gadgets to the Internet. The phrase Internet of Things refers to networks that link gadgets to the internet and share data with the user. These sensors are constantly producing data that indicate how effectively the devices are performing. The IoT platform collects data from various sources, analyses it, and extracts relevant information based on the needs.


    Neural Networks are machine learning algorithms that pre- dict outcomes from a large input of a data set. It is a type of information processing system, similar to the biological system of the brain, that uses non-linear variables to predict output. It is composed of multiple inputs known as neurons, each of which has a weight that indicates its influence and strength with the connected neuron. The transfer function is used to transport data from the input to the output. The neural network is composed of three layers of neurons that are interconnected. The neurons in each layer are connected to one another. The input layer stores all the data, while the output layer responds to the input. Between the input and output layers, there is a hidden intermediate layer that performs data processing.

    Fig. 1. Neural Network


    A number of wireless sensors, including a pH sensor, turbidity sensor, conductivity sensor, color sensor, and DO sensor, are coupled to the NodeMcu controller in the proposed system. The microcontroller is interfaced with a GSM module that allows it to communicate with the phone or other devices. The equipment is installed in residential tanks to test the water

    quality. The controller receives data from the sensors on a continual basis. The data is collected in a database, and the findings are transmitted to neural networks on a monthly basis for analysis. When the water is on the edge of being polluted, the user is cautioned to take further precautions to prevent drinking contaminated water. The suggested system is depictedbelow:

    Fig. 2. System Architecture


    The device was placed in a household tank on a regular basis to test the water. The standard values of the waters properties were defined as a limit for water quality in order to evaluate degradation.


      The system comprises a NodeMcU microcontroller, which is built around a famous inexpensive system-on-chip, ESP8266. It has a Wi-Fi module that allows it to easily connect to the user and convey the expected result. The pH sensor, temperature sensor, conductivity sensor, dissolved oxygen sensor, total organic compound sensor, colour sensor, and turbidity sensor are all interfaced with NodeMcU in the proposed model. These sensors collect data from the water and send a wave signal to a cloud server, which records the data from the gateway in a database for analysis. Using a neural network, the acquired data is then used to predict water contamination in advance.


    Matlab was used for implementation, and a neural network method was used to predict the outcome. The usage of neural networks is a better way to evaluate and model data. It analyses data through a network of linked neurons. Three different layers are present in the model – the input layer, hidden layer and the output layer. The datasets were collected continually for a year and are found to be statistically consistent, and represent the same statistical issue. To forecast the data, a total of 198 datasets were used. These datasets are routed through networks to produce outputs. The target output is obtained during the training phase. The data is divided into

    Fig. 3. Temperature Parameter

    three categories: training, testing, and validation, all of which have an impact on the networks performance.

    The training data contains 80% data, which is made up of 70% training set and 30% testing set. On the training set, the network is trained. On the dataset, this trained network is used. To predict the data, a temporal frame is established. To anticipate the accurate output, 100 neural network layers were employed. The true and projected values are displayed on the graph.

    Fig. 4. pH parameter

    To calculate the prediction, the neurons are assigned thefollowing function. Let 1….m denote the number of neurons in

    the system that accepts x1……xn +1 biassed inputs and outputs:

    hw, b(x) = f (WiXi + b) (1)

    where f represents the activation function

    f (z) = 1/(1 + exp(z)) (2)/p>

    The data in Table I is obtained from the WHO (World Health Organization) standard values. These standard values were used to compare expected values and to send an alert to the user when any of the parameters reached their extreme values before the water became tainted.


    The study provides a frugal technique for eliminating water pollution in residential overhead tanks. IoT devices are used to

    assess water quality, and machine learning algorithms are used to forecast potential water pollution problems. To gather water parameters, the proposed system comprises multiple sensors interfaced with NodeMcU. The user is notified before the water turns contaminated. The implemented solution protects the water from pollution while still being cost efficient. The projects future scope includes detecting illnesses caused by numerous factors and devising the most effective plan to cleanthe tank.


    1. Ping Liu Jin Wang Arun Kumar Sangaiah Yang Xie Xinchun Yin, 2019. Analysis and Prediction of Water Quality Using LSTM Deep Neural Networks in IoT Environment, Sustainability, MDPI, Open Access Journal, vol. 11(7), pages 1- 14, April.

    2. K. Gopavanitha and S. Nagaraju A low cost system for real time water quality monitoring and controlling using IoT||, IEEE Conference paper, August 2017.

    3. Manish Kumar Jha ; Rajni Kumari Sah ; M. S. Rashmitha ; Rupam Sinha ; B. Sujatha ; K. V. Suma Smart Water Monitoring System for Real-Time Water Quality and Usage Monitoring||,IEEE Conference paper,july 2018

    4. Asma Al Khaili, Aisha Al Mamari, Hoda Amer and Walid IbrahimAn Affordable System for Remotely Monitoring Water Quality in Residential Water Tanks||,IEEE paper, November 2018

    5. Vaishnavi V. Daigavane, Dr. M.A Gaikwad. ||Water Quality Monitoring System Based on IOT|| 2017 Advances in Wireless and Mobile Com- munications, Nov 2017 ISSN 0973-6972

    6. Neural Network Basics using Matlab, jma- jak/Neuralnetworksbasics.pdf

    7. Thair S.K. , Abdul Hameed M. J. , and Ayad S. M., Prediction of water quality of Euphrates river by using artificial neural network model ,International Research Journal of Natural Sciences Vol.2,No.3,pp.25-38, September 2014

    8. Nikhil Kumar Koditala ; Purnendu Shekar Pandey,|| Water Quality Monitoring System Using IoT and Machine Learning||, IEEE paper, August 2018

    9. Najah,A. El-Shafie,O. A. Karim,Amr H. El-Shafie Application of artificial neural networks for water quality prediction||, May 2013, Volume 22, pp 187 201.

    10. Resources||, Resources Internet of Things World Forum,

Leave a Reply