Internet of Things (Iot) Based Water Quality Monitoring System
Internet of Things (Iot) Based Water Quality Monitoring System
Internet of Things (Iot) Based Water Quality Monitoring System
ABSTRACT : In the coastal area of Bangladesh drinking water is short supply at everywhere for its complex
hydro-geological forms. Furthermore, natural disaster, trans-boundary river issues make safe water supply
difficult as compared to other portions of the country. Toxins from industrial sources may involve worry against
accomplishing all-inclusive and impartial access to protected and reasonable drinking water for the coastal areas.
it very well may be said that drinking water supply near the house is essential human right and fundamental for
leading healthy life. To lessen the water related illnesses and prevent water contamination, we need to quantify
water parameters, for example, pH, Turbidity, Temperature, Dissolved Oxygen, Salinity. For exact observing of
water quality, we built up an IoT based water quality measurement system which is low cost and sustainable. In
this work we proposed a smart sensor interface device that can sense the water quality parameters and effectively
generate data in an online system for showing real-time measures of water quality parameters. It integrates
drinking water quality measurement by different types of sensors. These sensors relate to Arduino for the
purpose of monitoring the parameters of water quality. For transmitting the values, we create a serial
communication between Arduino and NodeMCU which will show the data on an online system (web interface).
A QR code will be attached with every water source for accessing it easily by any user. They can scan the QR to
get sure whether the water is safe to drink or not. The Government can use this system to get information of
area’s water quality. This system can be also implemented on agriculture related applications and in industrial
fields. The design, development and implementation of an IoT based system will help the authorities take the
necessary steps to perform proper solutions for the affected area.
KEYWORDS - IoT, Water Quality Monitoring, Real-time system, Turbidity, pH, Temperature, Dissolved
Oxygen, Salinity, Arduino, NodeMCU.
I. INTRODUCTION
With rapidly rising population in Bangladesh, Fresh Water Management is very much essential which demands
an increase in agricultural, industrial and other requirements. The quality of fresh water is characterized by
“chemical, physical and biological” content. Monitoring the water quality helps in detecting the pollution in
water, toxic chemical and contamination. The traditional method still in vogue entails collection of water
samples, analyzing it in lab and advice for any water treatment and so forth. Current water pollution monitoring
method takes place in 3 main steps
Water sampling
Testing samples
Investigative analysis.
All these 3 steps are very expensive, difficult, time-consuming, need expert advice and less efficient. So, with
the advent of technology, automation can be brought in water quality monitoring in taking action appropriately
rather than relying on manual process. So, in automating the water quality monitoring some amount of
technological innovation has creeped in which would help in monitoring the quality of water rather than relying
on manual process [9]. The quality of the shallow aquifers in and around the textile, bleaching and dyeing units,
which use a wide variety of chemicals and dyes at Dhaka, Narayanganj and Gazipur and their environs are
highly polluted due to the indiscriminate discharge of untreated effluents in the nearby low-lying lands and
rivers and found unsuitable for all purposes. The riverbank and they are using water from the river and
discharging the treated and untreated effluents. The people living in the downstream are using the water for their
irrigation, drinking and other domestic activities. There is need of developing better methodologies to monitor
the water quality parameters in real-time [1].
We developed the model for testing the water sources and the data is uploaded over the internet are analyzed.
This is based on wireless communication system. Such communication systems have a very significant
commercial value, with wireless sensor networks continuing to grow, more and more countries showing great
interest [6]. The system will also warn the remote user, when there is a deviation of water quality parameters
from the pre-defined set of standard values. The aim of this paper is twofold. One is to present a basic model of
system which is low cost and less complex. Second, is to analyze the data to compare with Water Quality Index
(WQI)[8].The nature of water is assessed dependent on its physical, concoction, and organic boundaries. With
the target of giving an overall representation of the water quality dependent on all estimations, exertion has gone
into creating Water Quality Indices (WQIs) [14] A Water Quality Index (WQI) is a measure by which water
quality can be estimated for various purposes. WQI can be used to predict whether the water is suitable for
drinking purpose, agriculture purpose or aquatic organisms etc. WQI can be measured on the scale 0 to 100.
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
framework to provide satisfactory QOI experience in IOT sensory environments is studied. Contrary to past
efforts, it is transparent and compatible to lower protocols in use and preserving energy-efficiency in the long
run without sacrificing any attained QOI levels. [4]
Arduino Uno : Arduino is an open-source hardware and software company, project and user community that
designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices. Its
products are licensed under the GNU Lesser General Public License (LGPL) or the GNU General Public
License (GPL).
Arduino board designs use a variety of microprocessors and controllers. The boards are equipped with sets of
digital and analog input/output (I/O) pins that may be interfaced to various expansion boards ('shields') or
breadboards (For prototyping) and other circuits. The boards feature serial communications interfaces, including
Universal Serial Bus (USB) on some models, which are also used for loading programs from personal
computers. The microcontrollers can be programmed using C and C++ programming languages. In addition to
using traditional compiler tool chains, the Arduino project provides an integrated development environment
(IDE) based on the Processing language project [5].
Node MCU : NodeMCU is a low-cost open source IoT platform. It initially included firmware which runs on
the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which was based on the ESP-12 module Later,
support for the ESP32 32-bit MCUwas added. NodeMCU is an open source firmware for which open source
prototyping board designs are available. The name "NodeMCU" combines "node" and "MCU" (micro-controller
unit). The term "NodeMCU" strictly speaking refers to the firmware rather than the associated development kits.
Both the firmware and prototyping board designs are open source. The firmware uses the Lua scripting
language. The firmware is based on the eLua project, and built on the Espressif Non-OS SDK for ESP8266. It
uses many open source projects, such as lua-cjson and SPIFFS. Due to resource constraints, users need to select
the modules relevant for their project and build a firmware tailored to their needs. Support for the 32-bit ESP32
has also been implemented.
pH Meter : The pH sensor Module consist of pH sensor also called as pH probe and a signal conditioning
board which gives an output which is proportional to the pH value and can be interfaced directly to any Micro-
controller. The pH sensor components are usually combined into one device called a combination pH electrode.
The measuring electrode is usually glass and quite fragile. Recent developments have replaced the glass with
more durable solid-state sensors. The preamplifier is a signal conditioning device. It takes the high-impedance
pH electrode signal and changes it into a low impedance signal which the analyzer or transmitter can accept.
The preamplifier also strengthens and stabilizes the signal, making it less susceptible to electrical noise. pH and
ORP probes are both used for measuring the acidic intensity of liquid solutions. A pH problem measures acidity
on a scale from 0 to 14, with 0 being the most acidic and 14 being the most basic. Similarly, an Oxidation-
Reduction Potential (ORP) probe returns a voltage proportional to the tendency of the solution to gain or lose
electrons from the substances which is linked directly to the pH a substance.
Fig. 4. pH Meter
pH meter is an analogue sensor and send analogue data to Arduino. We convert it to real-world data. pH meter
returns voltage (0-5) where 0 indicates water is extremely acidic. Voltage is increased as the acidity level is
decreased, and base level is increased. Maximum voltage will be 5 for extremely basic solution. So, here we
multiply voltage by 2.8 and get the expected pH range.
Turbidity Sensor : The Turbidity Sensor measures the turbidity of fresh-water or seawater samples in NTU
(Nephelometric Turbidity Units, the standard unit used by most water collection agencies and organizations). Its
small, sleek design and simple setup make it easy to use at the collection site. In addition to water quality
studies, it can also be used to monitor precipitate formation or algae and yeast populations in chemistry and
biology classes. The Turbidity Sensor includes high-quality Hach StablCal™ 100 NTU standard for quick
calibration and a high-grade glass cuvette for water sample.
The turbidity sensor detects water quality by measuring level of turbidity. It is able to detect suspended particles
in water by measuring the light transmittance and scattering rate which changes with the amount of total
suspended solids (TSS) in water. As the TTS increases, the liquid turbidity level increases.
Interfacing with Arduino : This time we will discuss about how to access the Turbidity Sensor or Arduino
water turbidity sensor. We converted the voltage to NTU. The working principle of this turbidity sensor is the
same as the proximity sensor because there is a photodiode LED as a transmitter and a photo diode (receiver).
And this sensor utilizes the light emitted on the LED which then reflects the results of the light that will be read
by the sensor. So, the higher the level of turbidity of the water that will be detected, the level of light reflection
received will be less, and vice versa. This Turbidity sensor provides analog and digital signal output modes.
In our experiment we observe that in pure distilled water the voltage level is 3.515 and for extremely polluted
water the voltage level is decreased to 0.2. In NTU the range for turbidity is .25 to 100 where 0.25 NTU
indicates pure distilled water and 100 NTU indicates extremely polluted water. So, our analog value (0.2 to
3.65) will have to be converted to digital value in NTU (100 to .25). We have to generate a straight-line equation
which will be satisfied those value. The equation of straight line passing through two points (x1, y1) and (x2,
y2) is
𝑥 − 𝑥1 𝑦 − 𝑦1
= (1)
𝑥1 − 𝑥2 𝑦1 − 𝑦2
For analogue voltage 0.2 NTU value will be 100 and for voltage 3.7 NTU value will be 0.25.
So, two points are (0.2, 100) and (3.7, 0.25). And the straight-line equation will be
𝑥 − 0.2 𝑦 − 100
= (2)
0.2 − 3.7 100 − 0.25
y = 105.7-28.5x
Temperature Sensor : The Dallas Temperature Sensor is a 1-wire programmable Temperature sensor from
maxim integrated. It is widely used to measure temperature in hard environments like in chemical solutions,
mines or soil etc. The constriction of the sensor is rugged and also can be purchased with a waterproof option
making the mounting process easy. It can measure a wide range of temperature from -55°C to +125° with a
decent accuracy of ±5°C. Each sensor has a unique address and requires only one pin of the MCU to transfer
data so it a very good choice for measuring temperature at multiple points without compromising much of your
digital pins on the microcontroller.
The dallas component allows us to use your DS18b20 (datasheet) and similar One-Wire temperature sensors. To
use dallas sensor, first define a dallas “hub” with a pin and id, which you will later use to create the sensors. The
1-Wire bus the sensors are connected to should have an external pullup resistor of about 4.7KΩ. For this,
connect a resistor of about 4.7KΩ (values around that like 1Ω will, if we don’t have massively long wires, work
fine in most cases) between 3.3V and the data pin. The dallas sensor component (or “hub”) is an internal model
that defines which pins the ds18b20 sensors are connected to. This is because with these sensors you can
connect multiple sensors to a single pin and use them all at once.
Salinity Sensor (EC) : Salinity is the measurement of saltiness in water. This is usually measured by following
formula
𝑆𝑎𝑙𝑖𝑛𝑖𝑡𝑦 = (𝑔 𝑠𝑎𝑙𝑡/𝑘𝑔 𝑠𝑒𝑎 𝑤𝑎𝑡𝑒𝑟)
Salinity can be measured by passing an electric current between the two electrodes. The electrical conductivity
of water is influenced by the concentration of dissolved salt. Salts increase the ability of a solution to conduct an
electric current. So, a high EC value indicates high salinity level. High salinity level means saltiness of water is
high. It is an analog sensor which returns analog voltage value. Analog voltage must be converted to digital
value. The higher the saltiness, the higher the conductivity.
Analog Dissolved Oxygen Sensor : The dissolved oxygen (DO) is a dissolved oxygen in water. The oxygen
dissolves from the ambient air through diffusion; water aeration that has tumbled over falls and rapids; and as a
photosynthesis waste product. A simpler formulation is given below
This sensor is Compatible with Microcontrollers like Arduino. It is used to measure dissolved oxygen in water,
to reflect the water quality. It is applied in many applications and fields such as agriculture, aquaculture,
environment monitoring and so on. There is an old saying about fish conservation, "Good fish deserves good
water." For aquatic species good water quality is very critical. One of the essential parameters for representing
the water quality is the dissolved oxygen. Low dissolved oxygen in water may cause breathing problems for
aquatic species, which can endanger their lives.
logic level converter features four bi-directional channels, allowing for safe and easy communication between
devices operating at different logic levels. It can convert signals as low as 1.5 V to as high as 18 V and vice
versa, and its four channels are enough to support most common bidirectional and unidirectional digital
interfaces, including I²C, SPI, and asynchronous TTL serial. As digital devices get smaller and faster, once
ubiquitous 5 V logic has given way to ever lower-voltage standards like 3.3 V, 2.5 V, and even 1.8 V, leading to
an ecosystem of components that need a little help talking to each other. For example, a 5 V part might fail to
read a 3.3 V signal as high, and a 3.3 V part might be damaged by a 5 V signal. This level shifter solves these
problems by offering bidirectional voltage translation of up to four independent signals, converting between
logic levels as low as 1.5 V on the lower-voltage side and as high as 18 V on the higher-voltage side, and its
compact size and breadboard-compatible pin spacing make it easy to integrate into projects.
We need to connect HV and GND pin to high voltage device (Arduino). LV and GND pin will be connected to
low voltage device (NodeMCU). Lefts pin will be connected for serial communication between two devices.
Serial Communication: We need to create a serial communication between Arduino and NodeMCU for
transmitting data to firebase through Wi-Fi protocol. NodeMCU is much faster than ESP8266. So, here we use
NodeMCU for transmitting data. And thus, serial communication is needed. In serial communication the sender
device sends data character by character. Here we are formatting a string to transfer data to receiver device
(NodeMCU). For serial communication we use level converter between sender and receiver because of voltage
difference. Software Serial allows serial communication on other digital pins using software to replicate the
functionality. Here we are using Software Serial to start Serial at 9600 Baud. In general case, the serial will start
at 115200 Baud Rate because NodeMCU works on that rate.
Firebase Connection : We use firebase real-time database for cloud server. Here all processed data will be
uploaded to firebase cloud server. Furthermore, we will analyze those data for make decision and statistical
representation.
Processing Data and Send Data to Cloud : Finally, all processed data is sent to firebase cloud server. Here
signal processing is done in Arduino and by serial communication it is sent to NodeMCU. Then NodeMCU is
connected with firebase cloud server through Wi-Fi protocol [10]
4.2 Implementation of the System: The system implemented with required sensors and other necessary
equipments are operated in real and the figure of the project is given below.
5.1 Web Architecture : First, we achieved data from sensor and send it to Firebase through NodeMCU. The
Firebase process the data and prepare into JSON format for showing into the section in Website. The Model is
given below,
Firebase Website
Sensor Data Processing
Database
Unit
We are going to discuss about how firebase database work in Real-time and we used the technologies which is
more efficient even in slow data rate. The quick organization system must be quick and simple to convey and
keep up [13]
5.2 Implementation of Firebase : Firebase provides a real-time database and back-end as a service. The service
provides application developers an API that allows application data to be synchronized across clients and stored
on Firebase's cloud. The company provides client libraries that enable integration with Android, iOS, JavaScript,
Java, Objective-C, Swift and Node.js applications. The database is also accessible through a REST API and
bindings for several JavaScript frameworks such as AngularJS, React, Ember.js and Backbone.js. The REST
API uses the Server-Sent Events protocol, which is an API for creating HTTP connections for receiving push
notifications from a server. Developers using the Realtime database can secure their data by using the
company's server-side-enforced security rules.
5.3 Realtime Data Analyzing with JavaScript : Alongside HTML and CSS, JavaScript is one of the core
technologies of the World Wide Web. JavaScript enables interactive web pages and is an essential part of web
applications. The vast majority of websites use it for client-side page behavior, and all major web browsers have
a dedicated JavaScript engine to execute it. As a multi-paradigm language, JavaScript supports event-
driven, functional, and imperative programming styles. It has application programming interfaces (APIs) for
working with text, dates, regular expressions, standard data structures, and the Document Object Model (DOM).
However, the language itself does not include. Any input/output (I/O), such as networking, storage,
or graphics facilities, as the host environment (usually a web browser) provides those APIs. We use JavaScript
because the browsers don’t need refreshing again and again to show the real data.5.4 Web Application Interface
We have developed a user-friendly Interface to showing the real-time data. Used latest technology of languages
and scripts to build this system. CSS and JavaScript are mainly having two important roles in frontend and
backend.
5.4 Accessing Web Application with QR Code : A QR code consists of black squares arranged in a square
grid on a white background, which can be read by an imaging device such as a camera, and processed using
Reed–Solomon error correction until the image can be appropriately interpreted. The required data is then
extracted from patterns that are present in both horizontal and vertical components of the image. We used QR
code on every water source which consists of the link of the website. If anyone wants to know if the data is safe
or not all he can do is to scan the QR code from any device connected with internet. He can get the real-time
data.
6.1 Measurement of WQI : The calculation of the WQI was done using weighted arithmetic water quality
index which was originally proposed by Horton (1965) and developed by Brown et al (1972) . The weighted
arithmetic water quality index (WQIA) is in the following form:
𝑛
𝑖=1 𝑤 𝑖𝑞 𝑖
𝑊𝑄𝐼𝐴 = 𝑛 𝑤 (3)
𝑖=1 𝑖
Where n is the number of variables or parameters, 𝑤𝑖 is the relative weight of the ith parameter and 𝑞𝑖 is the
water quality rating of the ith parameter. The unit weight (𝑤𝑖 ) of the various water quality parameters are
inversely proportional to the recommended standards for the corresponding parameters. According to Brown et
al (1972), the value of 𝑞𝑖 is calculated using the following equation:
𝑞𝑖= 100 [(Vi – Vid) / (Si – Vid)]
where 𝑉𝑖 is the observed value of the ith parameter, 𝑆𝑖 is the standard permissible value of the ith parameter and
𝑉𝑖𝑑 is the ideal value of the ith parameter in pure water. All the ideal values (𝑉𝑖𝑑 ) are taken as zero for drinking
water except pH and dissolved oxygen (Tripaty and Sahu, 2005). For pH, the ideal value is 7.0 (for natural/pure
water) and a permissible value is 8.5 (for polluted water). Therefore, the quality rating for pH is calculated from
the following equation:
𝑞𝑝𝐻 = 100 [(𝑉𝑝𝐻 – 7.0) / (8.5 – 7.0)]; where 𝑉𝑝𝐻 = observed value of pH.
Water Quality Index (WQI) = 𝑤𝑖 𝑞𝑖 𝑤𝑖 𝑞𝑖 / 𝑤𝑖 𝑤𝑖 = 696.75/8.5 = 81.97. Which is good water quality in
WQI. We have calculated the other water samples using above method. We get the values, 60.55 for lemonade
water, 35.65 for lime water and 22.46 for the polluted water sample.
VII. DISCUSSION
The optimum value for purifier water is near 7 always. As it is the same as the pH in human eyes and mucous
membranes. Low pH value in water mixed with lemon is harmful for human health because it can cause skin
irritation and eye burn if it goes into our eyes. As a result of this low pH value and other disinfectants won’t be
as effective as it was for higher value. On the other hand, pH value higher than 7.5 is basic water. The water
mixed with calcium hydroxides is Extremely Basic which is not safe for human. We also get the value of
turbidity parameter which showing us that the turbidity is also a big factor for human and aquatic organisms
also. The value which is less than 5 NTU is safe to drink. We observed the water from the purifier is about 2-3
NTU always. So, we can say it’s safe to drink. But the water which has greater value of turbidity 5 NTU is very
unsafe and mixed with other components, The Temp. of water is also a big factor for human body and also
agriculture and aquatic organisms. We can see the regular temperature is 17-30 degree Celsius.
Future Scope : This platform is open and modular: further (bio) electrochemical sensors can be added in the
future (such as novel types of pH sensors or specific sensors for trihalomethanes, a common toxic byproduct of
disinfection by chlorine). The huge benefits of high-resolution sensors miniaturization and dissemination in the
water distribution network are evident. The existence of Arsenic in water source can be measured by adding
more features and by the combination of sensors.
REFERENCES
[1] Nikhil Kedia, Water Quality Monitoring for Rural Areas- A Sensor Cloud Based Economical Project,
in 1st International Conference on Next Generation Computing Technologies (NGCT-2015) Dehradun,
India, 4-5 September 2015. 978-1-4673-6809-4/15/$31.00 ©2015 IEEE.
[2] Jayti Bhatt, Jignesh Patoliya, IoT Based Water Quality Monitoring System, IRFIC, 21feb,2016.
[3] (SECON), 978-1-4673-1905-8/12/$31.00 ©2012 IEEE
[4] Zhanwei Sun, Chi Harold Liu, ChatschikBisdikia_, Joel W. Branch and Bo Yang, 2012 9th Annual
IEEE Communications Society Conference on Sensor, Mesh and Ad Hoc Communications and
Networks
[5]. User Manual Arm7-LPC2148 Development kit-Pantech Solutions.
[6] Chuanzhen, S. (2015, June). Applications of Wireless Sensor Network in the Field of Production and
Distribution. In 2015 8th International Conference on Intelligent Computation Technology and
Automation
(ICICTA) (pp. 225-227). IEEE.
[7] Sung, W. T., Chen, J. H., Huang, D. C., & Ju, Y. H. (2014, October). Multisensory real-time data
fusion
optimization for IOT systems. In 2014 IEEE International Conference on Systems, Man, and
Cybernetics
(SMC) (pp. 2299-2304). IEEE.
[8] Sneha S. Phadatare, Prof. Sagar Gawande. Review Paper on Development of Water Quality Index in
International Journal of Engineering and Technical Research, May 2016.
[9] K.S. Adu-Manu, C. Tapparello, W. Heinzelman, F.A. Katsriku, J.-D. Abdulai, Water Quality
Monitoring Using Wireless Sensor Networks: Current Trends and Future Research Directions, ACM
Trans. Sens. Networks. 2017
[10] L. Mainetti, L. Patrono, A. Vilei, Evolution of wireless sensor networks towards the Internet of Things:
A survey,(2011)
[11] Alippi, C.; Camplani, R.; Galperti, C.; Roveri, M. A Robust, Adaptive, Solar-Powered WSN
Framework for Aquatic Environmental Monitoring. IEEE Sens. J. 2011, 11, 45–55.
[12] Adu-manu, K.S.; Tapparello, C.; Heinzelman, W.; Katsriku, F.A.; Abdulai, J.D. Water Quality
Monitoring Using Wireless Sensor Networks: Current Trends and Future Research Directions. ACM
Trans. Sens. Netw. 2017, 13, 4.
[13] Ramanathan, N.; Balzano, L.K.; Burt, M.; Estrin, D.; Harmon, T.; Harvey, C.; Jay, J.; Kohler, E.;
Rothenberg, S.; Srivastava, M. Rapid Deployment with Confidence: Calibration and Fault Detection in
Environmental Sensor; Center for Embedded Networked Sensing: Los Angeles, CA, USA, 2006.
[14] Lumb, A.; Sharma, T.C.; Bibeault, J.-F. A Review of Genesis and Evolution of Water Quality Index
(WQI) and Some Future Directions. Water Qual. Expo. Heal. 2011, 3, 11–24.