IoT for Monitoring and Control of Water Quality Parameters

—This work presents an Internet of Things (IoT) solution to facilitate real time water quality monitoring by enabling the management of collected data from electronic sensors. Firstly, we present in detail problems encountered during the used data collection process. We discuss after the requirements from the water monitoring quality standpoint, data acquisition, cloud processing and data visualization to the end user. We designed a solution to minimize techni-cians’ visits to isolated water tower, we designed sensors achieving a lifespan of several years. The solution will be capable of scaling the processing and storage resources. This combination of technologies can cope with different types of environments. The system also provides a notification to a remote user, when there is a non-conformity of water quality parameters with the pre-defined set of standard values.


Introduction
The increase in human activity over the past century is having a devastating impact on our environment, directly resulting in a cost to human health.Every living creature needs water to survive; about 71% of the earth's surface is covered by water.Although water is abundant on earth, only 3.5% of the available water is fresh water, and approximately 20% of the world's population does not have access to safe drinking water.Water quality is an important parameter that affects all aspects of ecosystem and human well-being, such as the health of a community, the food to be produced, economic activities, and biodiversity.Also, it influences the levels of poverty, wealth, and human education.Ensuring the safety of water is a challenge due the excessive sources of pollutants, most of which are man-made.Therefore, the rapid pace of industrialization and greater emphasis on agricultural growth combined with latest advancements, agricultural fertilizers and non-enforcement of laws have led to water pollution to a large extent.Individual practices also play an important role in determining the quality of water [1].In developing countries, 80% of people are without access to potable water.In addition, some diseases are reported in many countries such as Cholera [2].
Poor water quality spreads disease causes death and hampers socio-economic progress, more than 485 000 deaths each year of which the majority are children in developing countries [3].Prediction models estimate that global consumption of water will double in the next 20 years, yet water quality assurance is undervalued and poses a significant threat to global health.Water distribution systems are vulnerable to intentional and inadvertent contamination.
Despite many technological advances, significant work remains to be accomplished for the purification of water.Generally, water quality is broadly defined as the "physical, chemical and biological characteristics of water required for the desired uses".The physical pollution of water is the altered limpidity and modified temperature, the chemical one is related to the nitrates, metals and other micro pollutants.The organic pollution leads to overconsumption of oxygen essential for aquatic life and the microbiological pollution with the introduction of pathogenic germs (bacteria, viruses, parasites) [4].
After use, water generally returns to the hydrologic system and, if left untreated, it can have serious environmental effects.So, water quality monitoring (WQM) can be described as a method for periodically sampling and analyzing water conditions and characteristics.Consumers expect water supply companies to deliver safe drinking water that meets both health quality standards and aesthetic requirements such as color, turbidity, taste and odor.Viewed from a management perspective, water quality is determined by the end use that is desired.For years, WQM mainly relied on a manual approach for water sampling and analysis, where a technician would travel to a water source, take samples of the water, and transport them to a laboratory for analysis.These WQM systems have several limitations due to the high spatiotemporal variability of the water physiochemical and/or microbial parameters [5].Additionally, different sources of errors are introduced including human errors during the sample collection (contamination of sample), sample analysis and data recording (statistical errors, round-off errors) and equipment (e.g., instrument malfunction) [6].These limitations led to a shift toward a more reliable approach for capturing water parameters to measure water quality.
From the late 2000s, particular new technologies are introduced to avoid some of these limitations.New sensors are developed using laser technology, biosensors, and optical sensors, to detect different water quality parameters in situ.In this case, technician uses in situ sensors on the water source to measure certain parameters on-site.More recent techniques based on different forms of remote water sensing have been considered, such as the use of satellites to capture images for analysis, optical sensors for monitoring the aquatic environment in situ and sensors for capturing water quality parameters at the water site.Although, these techniques enable the capture of water quality parameters on-site, they cannot address the need for continuous monitoring of the water source.Additionally, most of the time they do not allow for feedback control.
Currently in many counties like Algeria, the WQM procedure is manual and based on laboratory analysis.Laboratories are often far from water sources.Some mobile water testers are used to capture the chlorine level at the water source points but those kinds of devices are not available for all technicians.
The current procedure for WQM can be summarized in three phases: 1. Taking the samples 2. Laboratory analysis 3. Investigation (in case of analyses reveal a non-compliance with the quality-required parameters).
The three steps mentioned above are very expensive, difficult, time-consuming, need expert advice and less effective.The study we led in-situ reveals many other problems that do not enable an effective WQM: • Some water storage points are located in very isolated places (sometimes in mountains) which make access very difficult for technicians.Access is even more difficult during the winter.• A second problem related to the distance between storage points is the unavailability of fresh (real time) information.Since the time required to collect data is important and the large distance between storage points also makes it impossible to have continuous information about water quality, the intervention of technicians cannot be carried out in time when a problem occurs.• Difficulty to have a global view of the map of water quality is due to the unavailability of a global database on the current state of water quality.Each local agency uses a local database fed periodically by data collected by technicians.
Recent advances in the technologies of Wireless Sensor Network and robotics have led to significant progress notably in the applications of environmental telemonitoring.In the field of water monitoring, capabilities of automated measuring and wireless transmission have been widely designed by research institutes or deployed by environmental departments [7] [8].Although, online data gathering can be achieved by utilizing these systems, these later have been limited by their inadequacy and inflexibility in spatiotemporal quality evaluation [9].This paper presents the design and development of an IoT system for the telemonitoring of certain water quality parameters for achieving high-resolution spatiotemporal sampling.In the present work, an efficient prototype is presented and an effective online water quality management system is proposed, all are integrated into an IoT platform.The water parameters that are the focus of this project are pH, temperature, turbidity, ORP and chlorine.These parameters can indicate if there is a water contamination.Such systems would optimize resources and avoid expensive installations in-situ, allowing massive supervision of all fixed water sources (water towers) or mobile water sources (cisterns), in urban or in isolated areas.
Monitoring these sources would allow accurate diagnosis of key parameters affecting water quality, which is useful for technicians to localize where water quality is deteriorated, so decide what actions need to be implemented.At first, we assessed the energy requirements of the prototype for a standard parameters monitoring.The results suggest that it is possible to create a device with a lifespan of many years.In addition, we have developed a cloud infrastructure to meet the requirements of effective water quality monitoring.The proposal is based on criteria such as scalability, ease of deployment, openness and flexibility.
In most cases, given the particular requirements for effective WQM in tens or even hundreds of water sources far apart by hundreds of kilometers, it is necessary to design specific device for data transmission that should be able to monitor WQM without for short-term maintenance.Therefore, the most important issue for an IoT solution is the appropriate design of devices in terms of sensors, actuators and distant communication.
The remainder of this paper is structured as follows, Section 2 overviews some related work.In Section 3, we propose a domain model for WQM IoT-based.The proposed solution is presented in Sections 4 and 5. Finally, Section 6 concludes the paper and presents future work directions.

Literature Review
Water management is the activity of planning, developing, distributing and managing the optimal use of water resources, both qualitatively and quantitatively.To well understand the subject of this work, and to design a reliable quality model we reviewed out different existing systems developed by researchers.
Traditional water quality measurement involves manual collection of water at various locations, storing the samples in centralized location and subjecting the samples to laboratory analytical testing.Such approaches are not considered efficient due to the unavailability of real time water quality information, delayed detection of contaminants and not cost-effective solution.Hence, the need for continuous online water quality monitoring is highlighted in [10] [11][12] [13].
Smart water quality approaches have also been considered for lake and sea water applications.For such applications, distributed wireless sensor networks are required to monitor the parameters over a larger area and send the data monitored to a centralized controller using wireless communication.Such applications normally monitor parameters such as chlorophyll [9], dissolved oxygen concentration [14][15] [16], turbidity [17], PH [18] and temperature [19].
Aquaculture centers require water quality monitoring and forecasting for healthy growth of aquatic creatures [20][21] [22][23] [24].In [25] authors have developed biosensors using Arduino microcontroller to monitor animal behavioral changes due to aquatic pollution.The abnormal behavior of animals can be considered as an indication of water contamination.In [26] authors have proposed a smart water quality monitoring system to forecast water quality using artificial neural networks.Extensive tests have been carried out for a period of 22 months at isolated local area network and the data has been transferred to internet using mobile network technology.
Water quality monitoring in distribution systems is challenging in the context of management of distributed wireless sensor networks (WSN).A water distribution network for monitoring chlorine concentration has been presented In [25].Solar enabled distributed WSN has been proposed in [27] for monitoring parameters such as pH, turbidity and oxygen density.Water at different sites is monitored in real-time using an architecture composed of solar cell enabled sensor nodes and base station.Flexibility, low carbon emission and low power consumption are the advantages of the method proposed in the paper.A combined system for water and air quality measurement is proposed in [28] using additional sensors for measuring air temperature and relative humidity.
Most above works emphasis only on material aspect of the solution.Therefore, the whole solution is not clear.It is why we present in this paper a complete solution (material, platform, protocols) of an effective WQM system.

Domain Model for WQM System Based on IoT
We propose a conceptual model for WQM based on IoT.This model is based on works related to developing advanced systems using IoT technologies [29][30] [31].
Figure 1 shows the conceptual model, which is composed of domain entities, and the relationships that can exist between them.

Fig. 1. Domain model
The following table (Table 1) summarizes the terms used in to the domain model:

Physical entity
Any physical object that is relevant from a user or application perspective.
Example: Pallets, boxes containing consumer goods, cars, machines, fridges etc., as well as animate objects like animals and humans.
Thing Any computational or data element of an IT-based system.In addition, it's important to realize that Device entity will often perform in a bi-directional manner with the IoT Object at the edge of the network either acting as input devices (Sensors) or output devices (Actuators).

Resource
Computational element that gives access to information about, or actuation capabilities on a physical entity.

Private process
The private processes are considered as the set of processes of the enterprise itself and they are managed in an autonomous way to serve local needs.

Public processes
Public process is an aggregation of the private processes and/or Web services; they are seen as the participating partners.Public processes (governmental) span organizational boundaries.They belong to the public instances and have to be agreed and jointly managed by the partners Requirements Analysis Regarding the design of an IoT approach for WQM, this section discusses the requirements of each aspect of the solution, starting with the technical aspects of the thing design, cloud infrastructure and, finally, user interface.

Things
• Things should follow a modular design.
• The cost of individual thing should be low.
• The thing lifespan (including batteries) should be long without maintenance.
• The data exchange should be encrypted to warrant privacy.

Cloud
The non-functional requirements are the following: • It must enable the processing of both streamed and batch data gathered by the things.
• It should provide data stores based on NoSQL databases such as Cloudant or Mon-goDB.It should be flexible at the storage level, at least adding new resources dynamically and on-demand.• It must support secure access to the data stores • The functional requirements are the following: • It must provide access to the information about water source under monitoring, including an optimal way to query and fetch the relevant data from the data stores.• It must enable simple adding of additional processes.
• It should enable and facilitate the access to data visualization from client applications, through standard Internet protocols.

End user
For all type of users, the requirements are the following: • Users must be provided with web-based interfaces supported by as many browsers as possible.

5
Proposed Solution To realize this solution (Figure 2), we used a set of sensors attached to an Arduino microcontroller.A solar panel and batteries power this connected object.Therefore, it does not need an external power supply.An Ultrasonic sensor calculates the distance between the upper part of the water tower and the water level, to then calculate the available volume of the water.Once data is captured, it will be sent to the IoT Platform using the MQTT protocol, and more exactly to the Wiring module that connects the things and the user applications to the platform.Wiring module stores this data in a NoSQL database.The Wiring module application checks the water parameters sent against standards values, if an anomaly is detected, a notification is sent to the user application.The user application calculates via a set of formulas the volume of chlorine necessary to be dosed in the water tower according to several parameters such as the volume of water, the degree of chlorine used, the current chlorine concentration in the water tower etc.This value is sent to the connected object via the MQTT protocol.To make information reach more quickly different stakeholders, the IoT platform can be set up to notify them via SMS and emails.

Fig. 2. Proposed architecture
Water parameters that are the focus of this project are pH, temperature, turbidity, ORP and chlorine.These parameters can indicate if there is a water contamination.Conductivity gives an indication of the amount of impurities in the water, the cleaner the water, the less conductive it is.
The pH of the water is one of the most important factors when investigating water quality, as it measures how basic or acidic the water is.Water with a pH of 11 or higher can cause irritation to the eyes, skin and mucous membrane.Acidic water (pH 4 and below) can also cause irritation due to its corrosive effect.ORP is measure of tendency of a solution to either gain or lose electrons.A positive ORP reading indicates that water is an oxidizing agent, and a negative reading indicates a reducing agent (or antioxidant).Normal tap water has an ORP value between 200-400 mV.OPR is non-standardized water quality indicator, but WHO recommended that the ORP of drinking water should not exceed 60 mV.Chlorine is the most important substance for keeping drinking water healthy.To keep a certain concentration of the chlorine in the water, bleach is poured periodically into different storage installations such as water towers.

Used material
To realize the material part (the thing) of our project, we used the following components (Figure 3): • Wireless communication: An Arduino ATmega1281 does the conversion of the sensor output signals, which indicate the actual values.The data is processed and transmitted to the server via a SIM800c module.SIM800c is a full quad-band GSM/GPRS solution that supports the 850/900/1800 /1900MHz band, it can transmit voice, SMS and data over the Internet with low power consumption.We used a GPRS module for two main reasons: ─ The first is the absence of Wifi connection in the water towers.─ The second reason is the absence of an IoT service provider, such as LoRa and Sigfox in many countries.
Transmitted Data contains also GPS coordinates to allow end user application to know from which area data is sent.It makes the node portable, and avoids setting it in each water source.
• Energy: A rechargeable 9 V, 6600 mA_h battery is used to provide power for data collection and wireless transmission.It also stores energy harvested from a 12V and 115 x 85 x 3mm solar panel using a solar charge controller.It should be noted that the majority of water towers are not powered by electrical energy.• Used actuator: A dosing pump (12 V) to pour the bleach into the water tower.Doses to be poured are calculated by the end user application and sent to the pump using MQTT protocol.
All electronic components are deployed inside a waterproof buoy.

Communication protocols
To ensure efficient communication between different parts, we used the following protocols: MQTT: MQTT allows objects to send information about a given subject to a server that functions as a message broker (we used mosquito broker).The broker pushes this information towards customers who have previously subscribed in a specific topic [32].We chose the MQTT protocol for many reasons: • The MQTT exchanges data in real time, which helps us to create and send data notifications at the same time as an abnormal event detected by the thing.• It works for low power devices; in our case it is Arduino.
• An easy-to-use protocol due to the publication/subscription principle.
Http is a client/server protocol that uses the query/response principle.We have chosen Http to interact with the "MongoDB" database service.We use the GET methods to request a resource and the POST method to store the data.We chose the Http protocol for several reasons: • Since the MongoDB service uses NoSQL databases and stores data as documents with JSON format (JavaScript Object Notation), it is easy to query the data with an Http request.These data are then processed in different applications.
• The MongoDB response is a text file with the JSON format (JSON is easy to read by a human and interpret by a machine).Therefore, Http is the ideal solution to get the data.• Most programming languages such as java support Http protocol without the need for external libraries.
For displaying user-requested statistics, the end user application can interact directly with the database to retrieve data via Http, for example the pH of the last month of a chosen water tower.

Wiring module
Wiring module is located in the IoT platform.This module has the following features: 1. Specification of the necessary information of each thing, such as MQTT topic and the id.This id is used to identify received messages.2. Definition and application of the rules: in this part, we define the rules of each measure.Some rules need a higher or lower threshold such as water temperature and pH.It is via these rules that the platform can detect if there is an anomaly in water parameters.3. Notification creation: After defining the rules, we can apply them on data flow from different things and devices.If the rule condition is verified, a notification is created.4. Sending the notification: After preparing the notification, it can be sent to the broker, and then to all applications subscribed to this notification using MQTT protocol.5. Data storage: After receiving data from our things, we have to store them in a database.As we mentioned before, we used the NoSql MongoDB database to store data as JSON documents.
To well understand how our system works, in the following we will illustrate a real scenario of our system of collecting data using different sensors, sending it to the IoT platform, storing it in the database and finally visualizing the result for the end user.
1. Once the thing is launched, it will automatically authenticate to the IoT platform using an identifier.2. Once the data is captured, it will be sent to the IoT Platform using the GSM/GPRS module and via MQTT protocol.3. When the data is sent, the Wiring module will store this data on the MongoDB database using the Http protocol.4. Once the data arrives on the platform, the Wiring module will process it.If a rule is not verified, the Wiring module will create a notification with type, time and value, then sends it to all the applications of representation (mobile and office).
a) The Arduino will also receive this notification to activate an actuator.b) The end user will be informed on its mobile/desktop application, via an email or an SMS.
The user of the application can view the measured values via a mobile or desktop application in real time.A map is also displayed to show the different observed water sources (Figure 4).Information about water parameters of each water source is shown in a dashboard (Figure 5).In addition of wiring module, there is a device management module.This last allows remotely registering, organizing, monitoring and managing IoT devices on a large scale.

Formulas to calculate the volume of chlorine to be dosed
In this section, we will show formulas used by the developed system to calculate volume of chlorine (bleach) to pour in the water tower.It should be noted that in bleach, the concentration is measured in degree, and that a degree represents 3.17 g / liter.Steps we use to find the formula are the following: To test this system, we used a water reservoir of 800 liter and 12° bleach.We observed the concentration of chorine in water during several days.We noticed that all what we have used (thing, platform with formulas) could preserve a normal chlorine concentration according values specified in the wiring module.

Conclusion
In this paper, we proposed an end-to-end solution for Water Quality Monitoring.The main goal of the proposed architecture is to make the WQM process smart and precise by auto detecting and adjustment of any no conformity in water parameters.This ability makes this process autonomous what avoids daily human intervention for testing and pouring some substances in water such as chlorine.This human intervention become impossible in some isolated areas in winter.Tests proves efficiency of the proposed solution to maintain water parameters in limits specified by the regulations.Finally, future work will deal with data analytics that allow us to diagnose water quality sensor faults.

•
It must deny access to a non-authenticated user, including data visualization.• The design must provide a clear separation of the different end-user roles and prerogatives.• It must provide the definition of customized alarms to trigger the execution of different kinds of actions: notifications, processes... • It should support both batch periodic (that are executed on schedule) and interactive (launched by the user from the GUI) jobs.• It must support the exporting of data in different formats.http://www.i-jim.orgPaper-IoT for Monitoring and Control of Water Quality Parameters

1.
Calculation of the weight of chlorine required in grams (according to the standard): iJIM -Vol.14, No. 16, 2020

Table 1 .
Domain model terms an object that transforms the energy supplied to it into a physical phenomenon that provides work, modifies the behavior or the state of a system.
Example: Metering pumps, Light switch, Robot Device Technical physical component (hardware) with communication capabilities to other IT systems.A device can be either attached to, or embedded inside a physical entity, or monitor a physical entity in its vicinity.Example: Mobile Phone, embedded system, or sensor node with multiple sensors and/or actuators, any sensor, actuator, or gateway Tag Label or other physical object used to identify the physical entity to which it is attached.Example: RFID tag, QR code label Network resource Resource hosted somewhere in the network, e.g., in the cloud.Example: Cloud-based databases On-Device resource Resource hosted inside a device and enabling access to the device, and thus to the related physical entity.Example: Device driver, programming API Virtual entity Computational or data element representing a physical entity.Virtual entities can be either active or passive digital entities.