2018 International Conference on Computer, Control, Electrical, and Electronics Engineering (ICCCEEE)
Design and Implementation of a Low-Cost Real-Time
In-Situ Drinking Water Quality Monitoring System
Using Arduino
Sami O. Osman, Mohamed Z. Mohamed, Alzain M. Suliman, Amjed A. Mohammed
Department of Electronics (Communications) Engineering
Sudan University of Science and Technology
Khartoum, Sudan
[email protected],
[email protected],
[email protected],
[email protected] Abstract— Water can be considered as an important limited signaling, or both, of various water characteristics, often with
and critical resource over the world. This significant resource is the aim of assessing conformity to specified objectives” [3].
essential for agriculture, industry and for creature’s existence on Traditionally, water quality monitoring relied on a manual
earth including human beings. Water quality monitoring is approach for water sampling and analysis [2]. These traditional
becoming increasingly important due to the rapid presence of
techniques are essentially laboratory-based and follow a fairly
several different sources of pollutants and contamination. This
paper presents an approach to build an effective low-cost, real- simple workflow: samples collection, transportation and finally
time and in-situ water quality monitoring system using arduino analysis through specialized lab-instruments to characterize
microcontroller. The proposed approach aims to design a low- water quality [2] [4]. Although, the current traditional
cost system for real-time and on-site water quality monitoring monitoring approach is able to provide a thorough analysis and
using low-cost and accurate commercial off-the-shelf sensors and insight into water quality, and definitive confirmation of water
arduino programming language. The main aim of this work is to contamination, it has several limitations such as [2] [4]: a) time
design a monitoring system that can overcome some of the and labor-intensive and has a relatively high costs (equipment,
limitations of traditional water quality monitoring systems in operation and maintenance costs) b) requires the use of
terms of high-cost and non real-time operation. In addition, the
specialized and sophisticated instruments (such as: mass
performance of the proposed system through conducting several
experimental tests is evaluated. Experimental results show that spectrometry and ion chromatography) and trained staff c)
the proposed system is capable of accurately monitoring the rapid response and control measures may be lost because these
water quality continuously and in a timely manner with low cost. techniques are time consuming due to their dependence on
human interactions and the need for transportation of the
Keywords—Water quality monitoring, turbidity sensor, pH samples. Nevertheless, such lab-based techniques are still
sensor, conductivity sensor, GPIO, Arduino Uno microcontroller. dominating the water quality monitoring approaches [2].
Therefore, in light of all these limitations, there is a need for a
I. INTRODUCTION
more efficient monitoring approach. The United States
Water is one of the basic ingredients of life that is essential Environmental Protection Agency (EPA) carried out an
for the survival of all living organisms and for preserving the extensive laboratory experiment [5] to investigate the relation
ecosystem. In fact, clean drinking water is a valuable and between changes in water parameters and several water
critical resource required to sustain life and the quality of contaminants. The main conclusion was that many of the
drinking water plays a very important role in the well-being chemical and biological contaminants employed have an effect
and health of human beings [1]. Nowadays, water quality on many water parameters including: potential hydrogen (pH),
degradation and contamination issues can be directly attributed Turbidity (TU) and Electrical Conductivity (EC). Thus, by
to a variety of sources/ causes resulting from urbanization, detecting anomalous changes in water quality parameters using
industrialization and over exploitation of natural resources. In appropriate water quality sensors, water contaminants can be
this sense, it has become paramount and increasingly detected.
demanding to monitor the quality of water. Water quality A complete assessment of water quality requires the
describes the general composition of water with reference to its monitoring of a vast number of physical, chemical and
physical, chemical and biological properties (parameters) [1-3]. biological parameters. However, due to the unavailability of
Hence, assessing the quality of drinking water requires cheap commercial sensors for some water parameters it isn’t
monitoring various physical, chemical and biological feasible to monitor all these parameters. After a careful
parameters. literature survey, it has been found out that certain
Water quality monitoring is defined by the International physiochemical parameters give a general evaluation of water
Organization for Standardization (ISO) as: “the programmed quality, can be monitored reliably and at real-time using
process of sampling, measurement and subsequent recording or commercial-of-the-shelf (COTS) sensors and can be used to
978-1-5386-4123-1/18/$31.00 ©2018 IEEE
indicate the presence of several contaminants. Therefore the
following physiochemical parameters are selected to be the
focus of this research: pH, turbidity, conductivity and
temperature. The proposed system is based on the Arduino
Uno open-source microcontroller development board.
Arduino UNO is a small, low-cost, flexible and easy-to-use
open source hardware platform for microcontroller
prototyping. Arduino UNO is commonly used to create
electronics projects because it has several general purpose
input/output (GPIO) pins. As shown in Fig. 1, the Uno has a
total of 18 GPIO pins accessible by external hardware devices
of which 6 are analog input pins and 12 are digital I/O pins
where 6 of them can also be used as analog output pins.
Fig. 2. Water Quality Monitoring System Block Diagram
A. Data Collection Subsystem
This subsystem, and as shown in Fig. 2, acts as the first process
in the monitoring cycle and is considered the most pivotal
subsystem, since it contains the sensors which monitor (or
detect) the water parameters values. Thus, the success or
failure of the whole system depends majorly on the
performance of this subsystem.
1) Sensing Unit
The purpose of this unit is to collect the data of the desired
water quality parameters using a collection of sensors that were
chosen to achieve high performance. All sensors produce an
analog output except for the conductivity sensor which
provides digital output suitable for direct connection with a
Fig. 1. Arduino Uno Pinouts [6] digital pin of the Arduino Uno.
This paper proposes the design and development of a low- a) pH sensor
cost, real-time and on-site water quality monitoring system The potential hydrogen (pH) of water is one of the most
based on the Arduino Uno microcontroller that can be used by important factors when investigating water quality [9]. It is a
water consumers to monitor the quality of drinking water measure of how basic or acidic the water is, and is defined as
delivered by the distribution network of the public water the negative logarithm of the hydrogen ion concentration [2]
supplier. The contribution of this paper lies in the design and [14]:
development of a low-cost, real-time and continuous
monitoring system that can be used at the premises of
customers (water consumers).
This paper is organized as follows. Section II describes the Where is the concentration of the hydrogen ion in
methodology of this work. Section III presents the system water. The pH is measured on a scale from 0 to 14. Solutions
design and the implementation of the hardware and software with a pH less than 7 are said to be acidic, whereas, solutions
components. In section IV the results are presented and having a pH higher than 7 are basic or alkaline. Potable water
discussed, and finally our conclusions are drawn in section VI. should have pH in the range 6.5–8.5 [1].Water with high
alkalinity (pH of 11 or greater) can cause irritation to the eyes,
II. METHODOLOGY skin and mucous membrane, while, water with a high acidity
The design of the proposed monitoring system requires the (pH of 4 or less) can also cause irritation due to its corrosive
investigation and selection of the desired water quality effect [9].
parameters, sensors and controller. To facilitate the design and The proposed system uses the PH-4502C analog pH sensor
implementation of the proposed system, the system is divided from DIYMORE [10]. It measures the full pH range from 0 to
into two subsystems, as shown in Fig. 2: the data collection 14 and operates in the temperature range. The
subsystem and the data management and notification associated sensor probe is terminated in a BNC connector. This
subsystem. Each will be explained in details in this section. sensor enables continuous monitoring of the water pH value
through a connection to an arduino Uno analog pin.
b) Turbidity Sensor growth of microorganisms and may increase problems related
According to the WHO, turbidity, typically expressed as to taste, odor, color and corrosion [1]. On the other hand,
Nephelometric Turbidity Units (NTU), describes the electrical conductivity and pH measurements are temperature-
cloudiness of water caused by suspended particles (e.g. clay dependent [4], hence it is necessary to monitor the water
and silts), chemical precipitates (e.g. manganese and iron), temperature to be able to perform temperature compensation
organic particles (e.g. plant debris) and organisms [1]. for EC and pH readings [4] [9].
Turbidity can be caused by a variety of sources such as soil The temperature sensor was chosen to be the widely used
run-off, poor source water quality, poor treatment and, within LM35 analog temperature sensor. It generates and
distribution systems, disturbance of sediments and biofilms or has an accuracy of over a wide temperature range.
the ingress of dirty water through main breaks and other faults 2) Processing Unit
[1]. High turbidity levels reduce the palatability of drinking In addition to the sensing unit, the data collection
water, are associated with disease causing bacteria, and may subsystem also contains the processing unit. The processing
indicate the presence of hazardous chemical and microbial unit is considered as the brain of the monitoring system since it
contaminants [1]. performs all the vital data collection and processing functions.
Turbidity sensors working principle is based on the The major functions of this unit includes: reading the raw
property that solid matters suspended in water causes light sensors data, conversion of analog data into digital format,
transmitted through the water to be scattered, absorbed or conversion of data into usable measurements through applying
reflected rather than transmitted in a straight line through or appropriate equations, setting the threshold values and
into the water [14]. The turbidity sensor used in this work is the sampling frequency, processing the quality data, and finally
SEN0189 analog/digital turbidity sensor from dfrobot [11]. It triggering alarms.
has an operating voltage of 5Vdc, 40mA maximum operating This unit relies mainly on a microcontroller for performing
current and an operating temperature from . In its functions. A wide variety of controllers ranging from simple
addition, this sensor provides two operating modes: analog 8-bit to complex 32-bit microcontrollers have been proposed in
signal mode, and digital signal mode. Using the analog signal literature for fulfilling the processing functions of water quality
mode, the water turbidity data can be continuously acquired by monitoring systems [2] [13]. In this work, however, Arduino
connecting the sensor to an analog pin of the Arduino Uno Uno has been used because of its salient features that make it
controller. appropriate to this work, which includes: open-source platform,
c) Conductivity Sensor low-cost, easy to work with, has sufficient GPIO pins and
Electrical Conductivity (EC) is a quantification of the built-in ADCs. All these features make it a simple, yet,
ability of water to carry an electric current. It gives an powerful controller for electronic prototyping.
indication of the amount of impurities in the water, the cleaner The Arduino Uno controller is programmed to acquire the
the water, the less conductive it is [9]. Conductivity is also sensors quality data every 10 seconds, and alert the household
proportional to total dissolved solids (TDS) and directly user via triggering alarms whenever a quality parameter
associated with salinity [14]. Hence, a conductivity sensor exceeds the pre-defined safe limits recommended by
which measures the electrical conductivity of the water can international organizations such as the WHO [1], or national
also be used to determine approximately the water salinity and organizations such as the U.S EPA [7] and the Sudanese
amount of dissolved solids. Standards and Metrology Organization (SSMO) [8]. The
This work makes use of the EZO conductivity circuit from expected accuracy of the quality sensors and the safe quality
Atlas Scientific that provides accurate scientific-grade ranges, as defined by the WHO and SSMO, are tabulated as
conductivity measurements [12]. It is able to measure EC shown in Table I.
values within the range of and with an B. Data Notification Subsystem
accuracy of [12]. In addition to EC values, this sensor The second and final subsystem is the data management
can also provide the Total Dissolved Solids (TDS), salinity, and notification subsystem. It acts as the interface between the
and Specific Gravity (SG) values of water with a high water quality monitoring system and the end-user, its primary
accuracy. tasks are: alerting the user at real-time using both a visual
d) Temperature Sensor (LEDs) and audible (Buzzer) notification elements whenever
The temperature of water is a physical water quality the value of a water quality parameter exceeds the safe ranges,
parameter that is important as it controls the rate of chemical real-time visualization of the sensors data on an LCD,
reactions, and affects the acceptability of water to humans [1]. transferring data from data collection subsystem through serial
In addition, the amount of Dissolved Oxygen (DO) is communication protocol (UART) to be displayed on a user-
influenced by temperature [1] [2], where DO decreases as friendly computer Graphical User Interface (GUI). The GUI
temperature increases. Consequently, monitoring water proposed in this work is developed using the Python
temperature is of special importance in aquatic life monitoring programming language and it enables the user to monitor the
as high temperature changes affects the amount of Dissolved current state of the water through displaying real-time plots.
Oxygen (DO) necessary for fish growth. Furthermore, Moreover, the GUI has provisions that enable the adjustment
according to the WHO high water temperature enhances the of the sampling frequency and the threshold values of the
quality parameters, thereby increasing the flexibility of the The mute-alarm push-button was connected to digital
system. pin No. 3 of the Arduino Uno, which functions as an
As a summary, the data collection subsystem collects, interrupt pin.
process, and analyze the water quality data and take actions The pH and EC measuring probes were connected to
(trigger alarms) based on the values of the quality parameters. their respective sensor via a BNC connector.
TABLE I. PARAMETERS TO BE MONITORED AND THE WHO/SSMO
VALUES FOR SAFE DRINKING WATER
SSMO
Expected WHO
Parameter Units Standard (max.
Accuracy Standard
permissible)
pH
Turbidity
Conductivity
Temperature Acceptable
On the other hand, the data management and notification
subsystem provides means for audible and visual notification/
warning, visualization via an LCD and a GUI which not only
provides real-time plots of the quality parameters but also
means for adjusting the safety thresholds and sampling
frequency.
III. SYSTEM DESIGN AND IMPLEMENTATION
The proposed monitoring system comes complete with the
integration of both hardware and software
components/modules which are discussed deeply here in this
section.
A. Hardware Design and Implementation
The overall circuit diagram of the proposed system was
designed using Fritzing simulator as shown in Fig. 3. It is
comprised of the following hardware components: the PH-
4502C analog pH sensor, dfrobot SEN0189 turbidity sensor,
Atlas Scientific EZO conductivity circuit, LM35 temperature Fig. 3. System Circuit Diagram Using Fritzing
sensor, Arduino UNO microcontroller, Buzzer, indicator LED
and an LCD display. B. Software Implementation
According to Fig. 3, the sensors are attached to the arduino In addition to hardware materials several software
Uno board which represents the central part of the system since programs were exploited in designing the system, including:
it trigger alarms and performs all the major processing Arduino IDE platform, Fritzing simulator, Python pyCharm
functions including: A/D conversion of analog sensors IDE, PySide and the QT designer GUI development platform.
readings, conversion of data into usable measurements and The Arduino IDE resembles a simple word processor and is
detecting quality parameters that violates safety ranges. To used to compose and send the program codes to the Arduino
implement the hardware part of the proposed system the Uno. For the three analog sensors (pH, TU and Temperature),
following steps were done (as shown Fig. 3): code section responsible for making these measurements was
The Arduino Uno was connected to the breadboard; written so as to allow Arduino to take 50 readings in specific
along with the 5V and GND pins. time intervals and average them to make the output values
The pH, turbidity and temperature sensors were more reliable and stable. On the other hand, the Atlas Scientific
attached to analog pins A0, A1 and A2, respectively. digital EC sensor produced a fairly stable output, and doesn’t
The EC sensor serial pins were attached to digital pins require averaging of several readings. However, it was
4 and 5 of the Arduino Uno which were configured to observed that the EC sensor periodically produces an odd
function as hardware serial pins. reading with a high magnitude that doesn’t follow the output
The LCD was connected to pins 8 through 13 of the trend. To alleviate this problem and to produce a correct, stable
Arduino Uno. and smoothly varying output, a simple algorithm was
The LED and Buzzer notification elements were developed in which every three consecutive output readings of
connected to pins 6 and 7, respectively. the EC sensor were saved in an array and compared.
Accordingly, the reading with the magnitude that closely were placed in separate water containers and the temperature of
matches the output trend is selected. the three containers was measured continuously. The
The circuit simulation was carried out using Fritzing experiment proceeds following the steps outlined below:
software as mentioned above, which is an open source software Periodically, small and predetermined volume of
initiative to support designers and artists ready to move from lemon juice was being gradually added to the pH
physical prototyping to actual product [15]. sensor container. Accordingly, the pH sensor readings
Finally, the GUI was developed using the Python PySide were decreasing gradually since the water acidity was
GUI development package, and connected to the Arduino Uno increasing due to increasing concentration of lemon
through the serial port. Furthermore, the Python PyCharm IDE juice.
software program was used to analyze and visualize the data In a similar fashion, specific amounts of salt (solids)
through employing the Python data analysis modules (pandas, were added gradually to the EC sensor container at
numpy, scipy and matplotlib). regular intervals. Consequently, the EC and TDS
readings were increasing steadily as more salt (solids)
IV. RESULTS AND DISCUSSION was being added.
In this section, the performance of the proposed system is Similarly, small amounts of soil were being added at
evaluated in terms of accuracy and continuous and real-time regular time intervals to the turbidity sensor container.
operation. In addition, to demonstrate the working of the As a consequence the turbidity levels were increasing
proposed system design, this system was subjected to two at constant time intervals, as shown in Fig. 5.
experiments, the first of which involved measuring the quality Fig. 4 shows the experimental pH data that were gathered
parameters of solutions having standard and well-known during the period of eleven hours and at a sampling rate of 1
quality to determine measurement accuracy, and the second sample/minute. As can be seen from Fig. 4, the pH started out
involved adding specific quantities of contaminants (such as at a value slightly greater than 4.5 and then fluctuated rapidly
salt, soil and acidic lemon juice) to a predetermined volume of over time to achieve a maximum value close to 5.5 and a
clean water and measuring/recording the respective quality minimum close to 3.1. The mean score for pH was 3.8 which
parameters over an extended period of time. correspond to high acidity (high concentration of Limon juice).
Table II presents the results and accuracy achieved from the Fig.5 shows the changes in turbidity with time. It reveals,
first experiment. According to this experiment, the system the turbidity levels started out at a value close to 5.0 NTU and
proves a strong accuracy measuring the quality parameters. were stable around this value, until, as apparent, sudden and
large changes in turbidity levels occurred following the
TABLE II. OVERVIEW OF RESULTS ATTAINED FROM FIRST EXPERIMENT
addition of significant amount of impurities (soil). The
Standard-
Measurement Achieved %
minimum and maximum scores were 4.99 and 97.7 NTU,
Parameter Solution Units respectively. What is interesting in this data is that there were
Value Attained Accuracy
Value
time intervals during which turbidity levels were stable at a low
level, as shown in the same figure. This is attributed to the fact
pH that, over time, and since water is stored and isn’t running, soil
granules suspended in water settle at the bottom of the
container, thereby decreasing the turbidity levels.
The temperature variations (in Celsius) over the period of
Turbidity
eleven hours are shown in Fig. 6. The minimum and maximum
temperature values recorded were 21 and 27 , respectively.
Conductivity The mean temperature score was 22 .
To assess the real-time and continuous monitoring
capability of the proposed system a second experiment has
been conducted over a relatively long period of time (11 hours)
where a volume of clean water was gradually mixed with
several impurities (salts, soil and lemon juice) and the values of
the quality parameters were sampled every minute. The
experimental results were recorded, analyzed and visualized
via the GUI. A detailed explanation of how the second
experiment was set up and conducted is provided in the next
paragraph.
In the second experiment, and for sake of obtaining Fig. 4. Experimental pH Data Variation with Time
accurate results, the three quality sensors (pH, TU and EC)
there is a clear trend of increasing with time as the amounts of
impurities (salt) are gradually increased. From the same figure
it can be seen that increasing the amount of dissolved solids
(increasing TDS) increases the conductivity, as expected [14].
Fig. 5. Experimental Turbidity Data Variation with Time
Fig. 7. Experimental EC (Top) and TDS (Bottom) Data Variation with Time
V. CONCLUSION
This paper explained the design and implementation of a
low-cost drinking water quality monitoring system based on
Arduino Uno open-source hardware platform. An important
step in the implementation process was the calibration of the
Fig. 6. Temperature Variation with Time
quality sensors (EC, TU and pH) required to obtain accurate
As we have stated earlier in section II, temperature results. The sensors were calibrated at the SSMO maintenance
variations have a direct effect on the other parameters (pH, EC lab using standard calibration buffer-solutions. The results
and TU). Therefore, it is beneficial to find the relationship proved the accurate measuring of the proposed system and
between temperature variation and the other three quality showed that this system is able to provide reliable
parameters using numerical techniques. Changes in measurements. In addition, the results indicated that the
temperature and the other three parameters were predicted proposed monitoring system is capable of monitoring the
using numerical analysis, and the following equations were relevant water quality parameters continuously and at real-
formulated (where represents temperature and represents time. Furthermore, we have predicted the impact of
the respective quality parameter): temperature variation on the other quality parameters through
using numerical analysis techniques, and demonstrated that EC
A. Potential hydrogen (pH) vs. Temperature is proportional to the amount of Total Dissolved Solids (TDS).
The impact of temperature changes on the pH is predicted Although the study has successfully demonstrated the
by the following equation: design of a low-cost water quality monitoring system, it has
certain limitations in terms of the number of quality parameters
monitored and the capability of the system to detect the
presence of certain water contaminants. This work has thrown
B. Electrical Conductivity (EC) vs. Temperature up many questions in need of further investigation. It is
The impact of temperature on EC readings is predicted by recommended that further work can take into account the
the following equation: following issues: the effect of certain contaminants on water
quality parameters, development of contamination event
detection algorithms, improving the monitoring system
capabilities using modern ICT technologies such as Internet-of-
C. Turbidity (TU) vs. Temperature Things (IOT) and Wireless Sensor Networks (WSNs).
The impact of temperature on the TU readings is predicted ACKNOWLEDGMENT
by the following equation: Authors would like to thank and gratefully acknowledge T.
Mayada Abdelgadir for her valuable suggestions, discussions
and constructive comments. Thanks are also due to the
members of the maintenance lab at the Sudanese Standards and
As mentioned earlier in the paper, the EC sensor can also Metrology Organization (SSMO) for their help and who
be used to approximately measure the amount of Total without their technical assistance in the sensors calibration
Dissolved Solids (TDS) in the water. Fig. 7 shows the variation process this work would have been different. Finally, we are
of the EC and TDS values over time. As the figure shows, particularly grateful to Omer Mohammed from the U.S whom
without his sponsorship in attaining the quality sensors this [7] U.S. Environmental Protection Agency, “Drinking water standards and
health advisories,” Tech. Rep. EPA 822-F-18-001, 2018.
work would not have been possible.
[8] Water Guidelines in Sudan, Sudanese Standards and Metrology
REFERENCES Organization (SSMO) Publication, Khartoum, Sudan, 2015.
[9] N. A. Cloete, R. Malekian, L. Nair, “Design of smart sensors for real-
[1] Guidelines for Drinking Water Quality, 4th edition, WHO Press,
time water quality monitoring”, IEEE Access, vol. 4, pp. 3975-3990,
Switzerland, 2017.
2016.
[2] K. S. Adu-Manu, C. Tapparello, W. Heinzelman, F. Katsriku and J.
[10] DiyMore. PH-4502C pH Sensor [Online]. Available:
Abdulai “Water Quality Monitoring Using Wireless Sensor Networks:
https://www.diymore.cc
Current Trends and Future Research Directions,” ACM Trans. Sensor
Netw., vol. 00, no. 00, pp. 1-37, 2017. [11] Dfrobot. Turbidity sensor SKU: SEN0189 [Online]. Available:
https://www.dfrobot.com/wiki/index.php/Turbidity_sensor_SKU:_SEN0
[3] J. Bartram and R. Balance, “Introduction,” in Water quality monitoring:
189
a Practical Guide to The Design and Implementation of Freshwater
Quality Studies and Monitoring Programmes, London, UK: E&FN [12] Atlas Scientific. (2018). Conductivity EZO Circuit [Online]. Available:
Spon, 1996, ch.1. https://www.atlas-scientific.com/product_pages/circuits/ezo_ec.html
[4] T. Lambrou, C. Anastasiou, C. Panayiotou, and M. Polycarpou, “A low- [13] S. Geetha and S. Gouthami,” Internet of things enabled real time water
cost sensor network for real-time monitoring and contamination quality monitoring system”, Smart Water, vol.1, 2017.
detection in drinking water distribution systems,” IEEE Sensors Journal, [14] E. Roberts Alley, "Pollutant classification," in Water Quality Control
vol. 14, no. 8, pp. 2765–2772, 2014. Handbook, 2nd Edition, Alexandria, Virginia: McGraw-Hill, 2007, pp.
[5] J. Hall et al., “On-line water quality parameters as indicators of 42-51.
distribution system contamination,” J. Amer. Water Works Assoc., vol. [15] Fritzing. [Online]. Available: https://www.Fritzing.org
99, no. 1, pp. 66–77, 2007.
[6] Simon Monk, Electronics Cookbook: Practical Electronic Recipes with
Arduino and Raspberry Pi. Gravenstein Highway North, Sebastopol,
CA: O’Reilly Media, 2017.