Keywords

10.1 Introduction

Water pollution has received global attention in recent years due to undermining economic growth as well as the physical and environmental health of people. In particular, it has terrible effects on environment. It occurs due to mixing up of contaminated substances with subsurface groundwater, lakes, stream, rivers, and oceans. These pollutants can be from a variety of sources like sewage, discharge of toxic chemicals, radioactive materials, thermal pollution, food processing waste, insecticides, pesticides, drugs, and many more. Water pollution causes change in physical or biological properties of water which will create a detrimental effect on living organism. High concentration of BOD and TDS in the pollutants can cause depletion of oxygen present in the water. Furthermore, these pollutants can travel through food chain and get into human bodies, causing various diseases and death. Contaminated water creates waterborne diseases like dengue, cholera, diarrhea, and malaria. Conventional method of water monitoring involves manual collection of water sample from different locations in a regular period of time to provide the details of each location. These conventional monitoring techniques are lengthy, expensive, and time consuming. Manual monitoring system does not provide the exact values, and it needs more processing time. The frequent maintenance and repairing of instruments increase the operating cost too in this system. Furthermore, significant amount of resources get wasted when the instruments fail or when data go missing or erroneous. So an alternate technique, much simpler and a powerful and an efficient one, is needed for water quality and quantity monitoring in today’s scenario.

In order to collect the data on temperature, pH, and turbidity, the water quality monitoring system employs sensors. These parameters are measured in real time with suitable sensors and directed to the monitoring station in the remote location. Smart water quality monitoring through Internet of Things (IoT) is proposed to efficiently keep track on water characteristics. The usage of Internet of Things (IoT) with sensor nodes that have networking capability provides a better and suitable solution to the water monitoring system.

The water quality and quantity monitoring system through IoT involves three main subsystems: (1) data gathering subsystem, (2) data carrying subsystem, and (3) data governing subsystem. The water quality and quantity monitoring system through IoT is presented in Fig. 10.1.

Fig. 10.1
figure 1

Process of real-time water monitoring system

Water parameter monitoring subsystem involves various sensors for monitoring water metrics and a data transmission device to transmit the collected information from sensors to the controller. The controller collects and processes the data received from the sensor. The processed data from controller is transmitted to the cloud storage using wireless communication device in the data carrying subsystem. The data governing subsystem uses an application to acquire the information from cloud and displays it to the end user.

Sensors are typically used to detect the changes in an environment or a system and transmit the data for processing. In this work, the sensors are placed inside running or stored water source. The sensors convert the measured parameter into its equivalent electrical quantity. The converted physical parameter is processed by a controller and sent to the suitable application using appropriate communication technology. The technology used for communication can be chosen based on the type of application used. The application can be data governing system, data inspection system, or warning system based on the parameter to be monitored.

Sensors involved in the proposed system are (1) sensor for pH monitoring, (2) sensor for turbidity monitoring, (3) sensor for temperature monitoring, and (4) level and flow monitoring sensor.

pH scale for liquid generally varies from 0 to 14. In general, if the pH of water is less than 7, it can be treated as acidic, and if it is more than 7 pH, it can be considered as alkaline. So, measurement of pH in water is treated as an important indicator of water purity. pH is generally considered as measure of free hydrogen and hydroxyl ions in the liquid. It generally changes with the chemicals present in the pollutants. The solubility and biological availability of chemicals present in water are also determined by measuring the pH of water. pH of water is measured with pH sensor and sent to the controller for further processing.

Turbidity monitoring is important in water resources as it affects the growth of aquatic plants in the water stream. Increase in the turbidity of water reduces the amount of light for photosynthesis and also increases the temperature of water. Turbidity in the water occurs due to the suspended particles like clay, slit, tiny organic and inorganic organisms, and organic compounds that are soluble. Increase in the turbidity in the water is caused mainly due to human activity in industries and agriculture that causes the movement of suspended particles which get mixed into the water. During transportation of water through broken water line and rusted water pipes, the turbidity of water gets increased. The amount of light scattered by the suspended particles in the water is measured by turbidity sensor. If the level of turbidity in the water gets increased, the risk for gastrointestinal diseases in the human also increases. The World Health Organization (WHO) suggested that the turbidity measure in the water should not be more than 5 Nephelometric Turbidity Units (NTU) and that the ideal value of turbidity in water must be below 1 NTU.

Thermal pollution increases the temperature in water that in turn affects the reproductive system of human beings and metabolism of aquatic animals. Thermal pollution occurs when the heat gets released from coolers and heat exchangers in industrial processes that get exposed into water. Pollutants in the water become more toxic when the temperature increases, and the dissolved oxygen in the water also reduces when water becomes warmer. At the same time, when the temperature increases, H+ ions in the water also increase, and this makes the pH of water to get dropped. Water temperature can be measured with temperature sensor, and the electrical signal from the sensor is given to the controller in data processing subsystem.

Next, the proposed water quantity monitoring system comprises sensors like (1) level sensor and (2) flow sensor. Water distribution system generally has an infrastructure that collects, treats, and stores water and efficiently distributes it through the network of storage tanks and pipelines. The function of water distribution system is to supply appropriate quantity of water to customers with sufficient pressure, with minimal loss, safe, and in an economical way [1]. There are a wide variety of water sources like river extractions and ground water extractions, and it can be extracted from alternative sources like wastewater treatment process and desalination process also. Water flow through pipeline must be with sufficient pressure to avoid the contamination with underground water leakage and other user requirements. About 60% of population depends on the public water supply. There is a wide gap between demand and supply of water to the common people. The major issue in India is the sanitation facilities and safe access to water in both urban and rural areas. A large part of India falls under water scarcity where the availability of natural resources is not sufficient, so the efficient usage and distribution of water are necessary in current scenario.

Generally, water is stored in overhead tanks and underground reservoirs having inlet and outlet pipes fitted with the valves that are opened and closed for a scheduled time to manage the supply of water. Monitoring and control of this must be automated for the efficient distribution of water. Measurement of leakage of water is also quite important to avoid the wastage of water during distribution of water in pipelines. Wastage of water due to leakage in pipelines while transporting water from one place to another also paves the way for water scarcity in many places, and so it should be monitored and repaired shortly for further usage. While transporting water, there is also a chance for the quality getting affected due to the external parameters; therefore, this should be monitored and corrected before it is given to the public. In primitive method, water leakage in a rural area is located manually which took more time that leads to more loss of water and increases the demand in the receiving area. So, the sensors, meters, and analytical tools are required for monitoring and controlling the transmission and distribution of water.

Water quantity measurements include an ultrasonic sensor that measures the amount of water in the storage tank, and the flow of water in pipeline is measured with flow sensor that helps to know about the amount of water flowing through the pipelines. Water leakage is detected with the wireless sensor network that helps to keep tracking the location that has more water leakage through the data given by the sensors.

So this work proposes a system that monitors the water quality and also distribution of water for the domestic usage using IoT for a single home, and this can be extended to any civil structure.

This proposed work is organized as follows: Sect. 10.1.1 gives the review of existing system, Sect. 10.2 explains the proposed system, Sect. 10.3 gives results and discussion, and Sect. 10.4 elaborates the results obtained.

10.1.1 Overview of the Existing Systems

The existing water level monitoring system monitors the level of water, quality of water, and GSM module for sending the messages to the user. In this method, the water quality is measured by testing the water samples from the water tank. In these methods, water level is monitored by water level sensors. The water level sensors are made of plastics and may have the chance to be deposited by algae. The conventional method involves the collection of water samples from different locations manually. The water quality in the storage tank is usually measured in laboratories. These methods fail in identifying losses occurred in transmission lines and also get affected by the leakage problems. Lag in leakage monitoring system leads to the wastage of water in the unwanted places which in turn affects the people by water scarcity in the needed areas. In older methods, the leakage is identified manually and then the workers search hard to locate the leakage. This leads to loss of huge water from the pipelines and also increases the period of water scarcity in the terminal area.

Other method includes monitoring of water in the stored level in the large quantities like lakes, tanks. This method does not offer full functionality when the water is lost while transporting. Water level monitoring is done simply using electronic components which does not give the exact reading. In some methods, the water level is measured by calculating the water quantity input and output measurements. In this technique, any blockage in the outlet pipeline leads to misreading of the water level. In former methods, the deposits in the water tank are not considered, but they also contribute more in the water quantity and quality in the tank. Moreover, these methods allow knowing the level of water alone.

Smart water quality monitoring system deals with the data management subsystem that acquires, transmits, and analyzes the data [2]. Particularly, it deals with the subsystem that acquires the data and selects the parameters for water quality measurement, the techniques currently used for water quality monitoring through online, the locations for placing collecting stations, and interval of time for collecting the samples. In this work, the data network architecture chosen for data transmission and management system for the data communication involved is also studied. In this work, the techniques involved for water quality analysis and methods for data storage are also dealt.

Water quality monitoring using a smart sensing system deals with the design of new smart sensor used for monitoring water quality [3]. This new introduced technique measures the physical and chemical properties of water sample to calculate the water pollution parameters by utilizing the spectroscopic techniques. This is done by using a multisensor fusion approach, by utilizing artificial neural network algorithms. A set of water samples are tested successfully with the proposed smart sensor to estimate the value of chemical oxygen demand (COD). The estimated COD with this proposed smart sensor technique equals the value measured with a conventional technique.

Remote monitoring and smart sensing for water meter system and leakage detection speaks about the devices utilized for remote monitoring of quality and quantity of water. These electrical meters waste the energy significantly as they must be turned ON and OFF periodically [4]. This proposed work introduces a new metering scheme that uses the traditional mechanism by combining traditional mechanical devices with electronic water meters. This proposed method is a low-cost method, utilizing noncontact-type sensor with capacitive signal sensing method; moreover, in this method, the device is supplied with power only when the server requests for measured signal, so it consumes only less power. This method also includes a water quality monitoring technique that uses wireless network to detect the water leakage by performing software analysis done through a control center placed at the server. This system efficiently performs water management and has low power consumption, low human errors, and minimum wastage of water resources.

10.2 Proposed System

The proposed work involves sensors for the measurement of quality factors of water like pH, turbidity, temperature, and also the water level in the storage tank [5]. The flow diagram of the process of real-time monitoring system is presented in Fig. 10.1. The controller processes the values that are measured by sensor, and the processed data is transferred through Internet to the authorities. Arduino is used as a core controller in this proposed water quantity and quality metrics monitoring system.

The quantity of water in the storage tank is measured continuously with an ultrasonic sensor [6,7,8]. Measured value from the sensor is compared with the standard value, and if the water reaches the value below the standard, the Arduino interfaced with the ultrasonic sensor alerts the municipal authorities about the water level. The municipal authorities get alerted about the water level in the tank with the available data. Since the water level is monitored continuously, any sudden drop in the water level alerts the municipal authorities. This makes the municipal authorities to know about the leakage or any overuse of water in the particular area.

Flow sensor is connected to the outlet of the water pump from the lake or water resources and interfaced to an Arduino board along with a GPS module. Arduino is also connected to the RF module which transfers data to the next RF module placed after certain interval. This RF module is interfaced to another Arduino which receives and stores the data and sends it along with the data obtained from the flow sensor and GPS module to the next RF module. These data are then finally transferred to the Arduino placed in the last stage of the process, and from there, these processed data are transferred to the municipal authorities. Therefore, the information regarding the leakage of water in the pipelines from the tank will be intimated to the municipal authorities immediately by comparing the flow rate of the sensors. Along with this, the information regarding the leakage of water in the pipelines in different location can also be identified. This helps the municipal authorities to repair the leakage in short span of time that reduces the wastage of water and avoids water scarcity.

Turbidity sensor reads the amount of turbidity in the stored water. It also helps to know about the amount of dissolved particles deposited in the lower level of the tank. This deposition decreases the amount of water quantity in the tank and also leads to the development of many small parasites in the water which deploys the quality of water. Voltage output from the turbidity sensor varies in a linear manner to the amount of the suspended particles in the water. The voltage output from the sensor is coupled to the Arduino. This output from the Arduino is sent to the municipal authorities, so that they can know about the turbid nature of water in the tank. This makes the authorities to recheck the filters in the water reservoir pumps and make the water pure.

pH sensor helps to know the alkalinity of the water stored in the storage tank [9]. pH sensor with BNC connector interfaced to the analog input of Arduino can sense the change in pH value. The humans have high tolerance for the values of pH, but when the pH value become higher than 11, it causes problem in the skin, irritations in eye, and minimal gastrointestinal irritations. Any variation in the pH value of water in the storage tank from the standard value can be reported to the municipal authorities.

Negative temperature coefficient (NTC) thermistor measures the temperature of water in the stored tank. The resistance of NTC thermistor reduces when the temperature increases. Change in resistance for the change in the temperature cannot be measured directly with Arduino, the changes can be measured only as voltage. The voltage at a point between the thermistor and a known resistor is measured with an Arduino. If the temperature of the stored water increases above the desired level, the information about the change is given to the municipal authority.

The municipal authorities can access the data using smartphones, personal computer, and tablet from server module placed in the remote place. The service is available to the end users through the network, usually the Internet. This system stores the data, and this stored data can be accessed by the end user from any location through the Internet. A web page is created that allows the user to monitor and control the system. The web page gives information about pH value, turbidity, temperature variations, and amount of water in storage tank of a particular region. Through the IP address of the server placed for monitoring, the web page of particular area can be accessed [10].

The sensors and the modules utilized in the proposed water quality and quantity system are discussed below. Figure 10.2 presents the block diagram of the proposed water quality and quantity metrics monitoring system.

Fig. 10.2
figure 2

Water quality and quantity metrics monitoring system

10.2.1 Ultrasonic Sensor

Ultrasonic sensor works by the principle of “time of flight” using the speed of sound. It sends the short and high-frequency sound pulses at regular interval of time in the direction of medium. These pulses strike an object and reflect back from the object as an echo signal to the sensor. The distance to reach the target is calculated as the time interval between transmitting signal and receiving signal. The distance and level are calculated using Eqs. (10.1) and (10.2).

$$ \mathrm{Distance}=\left(\mathrm{Speed}\kern0.62em \mathrm{of}\kern0.62em \mathrm{sound}\kern0.62em \mathrm{in}\kern0.62em \mathrm{air}\times \mathrm{time}\kern0.62em \mathrm{delay}\right)\div 2 $$
(10.1)
$$ \mathrm{Level}=\left(\mathrm{Tank}\kern0.62em \mathrm{height}-\mathrm{Distance}\right) $$
(10.2)

In this work, ultrasonic sensor is placed on the top of the storage tank, and it sends an ultrasonic signal down to the bottom of the tank. These signals travel at the speed of sound and get reflected back to the transmitter. The time delay between transmitted and received signal is calculated using ultrasonic transmitter. This time delay changes linearly based on distance between the target surface and the transducer mounted on the surface, and it can be used to calculate the quantity of water in the storage tank. The medium of transmission of sound signal is usually air. The speed of the sound wave gets altered with medium temperature, and the presence of dust or any other environmental factors can also affect the signal transmission. A beam guide can be attached to the transducer for enhancing the performance of the system where dust and temperature affect the sound signal.

Advantage with the usage of ultrasonic sensor for liquid measurement is that of the technique used for measurement is a noncontact type that will not get affected by liquid density and pressure. Installation of ultrasonic transducer on the empty tank or tank with liquid is very easy and easily configurable.

The disadvantage of using ultrasonic sensor for water quality monitoring system is that it can be only used for measuring minimum liquid distance. Moreover, reading the reflections from smooth and curved surface is difficult and sensitive to temperature variations.

Principle of level measurement of water storage tank using ultrasonic sensor is presented in Figs. 10.3 and 10.4 shows the ultrasonic sensor used for the proposed work.

Fig. 10.3
figure 3

Principle of level measurement using ultrasonic sensor

Fig. 10.4
figure 4

Level measurement using ultrasonic sensor. (Source: IndiaMart)

10.2.2 Turbidity Sensor

Turbidity measurement is performed to check for the water clearness. Water cleanliness generally gets affected by clay, soil, and slit entering into the water from distributed places. Suspended particles adversely affecting the ecosystem can be the pollutants like chemicals, pesticides, and heavy metals. The historic data of the turbidity of water in different areas at different instant time can be maintained, and the occurrence of drastic change in the turbidity will be reported. The turbidity sensors work by transmitting a beam of light into the water to be tested. The suspended particles scatter the transmitted light, and the quantity of light reflected back determines the density of suspended particles. More the light gets scattered more the suspended particles in the stored water. Figure 10.5 shows the arrangement for principle of turbidity measurement, and Fig. 10.6 shows the turbidity sensor used in the proposed work.

Fig. 10.5
figure 5

Principle of turbidity sensor

Fig. 10.6
figure 6

Turbidity sensor. (Source: Thomson Electronics)

10.2.3 pH Sensor

In water quality monitoring, high or low pH values will be an indication of water pollution. pH sensor is used to measure the hydrogen ion activity in water, indicating its acidity or basicity. pH meter estimates the difference in electric field potential between the reference and pH electrode and displays the pH value. This arrangement comprises electronic amplifier, glass electrode, and reference electrode or a combination electrode. The electrodes are placed into the water that is to be examined for the quality and quantity metrics. Glass electrode used for pH measurement is designed specifically for measuring hydrogen ion concentration. The hydrogen ions in the stored water exchange the positive ions with glass bulb and create an electrochemical potential across the bulb. The reference electrode is made of metallic conductor and must be insensitive to the pH value of the water. On the immersion of reference and glass electrode in the water, the electric circuit gets completed. The difference in electrical potential created between electrodes is measured, amplified, and displayed as a pH value. The potential difference developed across the electrode is detected by the voltmeter. The Nernst equation gives the relation between ion movement and measured voltage.

The electrodes are sensitive to the contaminants, and cleanliness of electrode is essential to derive more accurate and precise results. Calibration must be done for glass electrode, as it will not produce a reproducible output over long span of time. The response of pH electrode is temperature dependent, and pH values of buffer solutions greatly depend on the temperature. Some electrodes have in-built temperature coefficient correction, so the calibration process correlates the voltage produced by the electrode with pH scale.

The principle of working of pH sensor is shown in Fig. 10.7, and pH sensor utilized in this proposed work is shown in Fig. 10.8.

Fig. 10.7
figure 7

Principle of pH sensor

Fig. 10.8
figure 8

pH sensor. (Source: Robokits)

10.2.4 NTC Thermistor

Thermistor is a thermal-sensitive resistor that produces high, precise, and predictable variation in resistance for the small variation in temperature. The resistance of NTC thermistor increases as the temperature decreases and the resistance value decreases as the temperature increases. As NTC thermistor provides a larger variation in resistance for °C change in temperature, and a small change in temperature can also be revealed very faster with higher accuracy. The effective operating range for NTC thermistor is −50 to 250 °C. Unlike other resistors, these are made of ceramics and polymers that are composed of metal oxides that are processed to get the desired form factor.

The principle of working of NTC thermistor is shown in Figs. 10.9 and 10.10 gives the NTC thermistor module used in the proposed work.

Fig. 10.9
figure 9

Principle of NTC thermistor

Fig. 10.10
figure 10

NTC thermistor. (Source: IndiaMart)

10.2.5 Flow Measurement

The orifice plate is used for the measurement of water flow in a storage tank. It is made of stainless steel of various grade and is a thin metal plate of diameter 1.5–6 mm in thickness with the hole bored at the center of plate. The bore diameter in the plate will be in the range of 30–75% of the inside diameter of pipe.

Principle of orifice plate is that when an obstruction is placed in the pipeline, a difference in pressure results. This difference in pressure measured with the upstream and downstream side of partially obstructed pipe gives the amount of fluid flow in the pipe. This pressure drop can be measured with a pressure gauge and varies based on the flow rate. The differential pressure measured with pressure gauge is directly proportional to the flow rate as per Bernoulli’s equation, and hence the pressure gauge can display the flow rate instead of differential pressure.

Orifice plate has no moving parts and is mechanically stable, simple, reliable for many years, and inexpensive. But it has less discharge coefficient and produces inaccurate results when the plate gets eroded. Moreover, its accuracy is dependent on density, viscosity, and pressure of fluids.

The principle of operation of orifice plate is shown in Fig. 10.11, and the flow sensor module utilized in the work is shown in Fig. 10.12.

Fig. 10.11
figure 11

Flow measurement

Fig. 10.12
figure 12

Flow sensor. (Source: Electronics hub)

The process of flow for the proposed work is shown in Fig. 10.13, starting from interfacing of sensors to Arduino and final intimation given to the user is shown.

Fig. 10.13
figure 13

Flow diagram of the proposed system

10.2.6 Arduino UNO

Arduino UNO is an open source platform that is used to develop IoT-based products. It consists of ATMega 38 microcontroller. The board has a set of digital input and output pins that can be interfaced to various expansion boards and circuits [11, 12]. Arduino can be powered with personal computer through USB or with external power supply. Processor utilized in Arduino is based on Harvard architecture. In Harvard architecture, program code can be stored in a flash memory and can be reprogrammed for any number of times, and the data is stored in data memory.

It has 14 digital input and output pins and six analog input and output pins. Arduino UNO can be programmed with Arduino IDE (integrated development environment) via USB cable. Some pins in Arduino have some specialized functions like UART (universal asynchronous receiver transmitter) for transmitting and receiving the data serially. External interrupt pins can trigger an interrupt on change in value, rising or falling edge and low value, PWM (pulse width modulation) pins, SPI (serial peripheral interface) pins, and AREF (analog reference) pins. By connecting a sensor to an Arduino board, the sensor values can be read and processed. The Arduino can be connected to Internet so that the sensor data can be monitored from remote place. The sensors can be connected directly to Arduino pins or using Arduino shield pins.

Arduino shield provides three-pin interface for connecting different sensors and output devices to Arduino. It is an easy way of connecting input and output devices to Arduino. It is a passive circuit that connects the Arduino pin to many connectors. The connector allows to connect various sensors, servos, relays, and buttons to Arduino. There are 13 ports for digital input and output and six analog ports for analog input. The digital port has 5 V power and TTL level signal (0 or 1), and analog input accepts 0.5 V DC input voltage and gives output voltage in the range 0.5 V. Arduino sensor shield system is connected to a 5 V system and to a 3.3 V system also.

The Arduino can be programmed directly by loading the program into it without the need of hardware programmer for doing programming or burning the program. This can be done with Arduino bootloader that programs the flash memory for any number of times.

In this work, five sensors like flow sensor, level sensor, turbidity sensor, temperature sensor, and pH sensor are connected to the five analog/digital pins of Arduino. The Arduino UNO has in built TCP/IP protocol stack that made Arduino to have access to Wi-Fi network. This collected data about the status of water quality and quantity from different sensors is given to municipal authorities. The RF module is used for communication between Arduino and sensors. Arduino UNO used in this work is shown in Fig. 10.14.

Fig. 10.14
figure 14

Arduino UNO. (Source: Amazon)

10.2.7 RF Module

RF (radio frequency) module is the cheapest mode of wireless communication. Communication between two Arduino modules can be done with RF module. RF module is made of transmitter and receiver pair that works at a radio frequency. It is based on amplitude shift keying (ASK) or of hook keying (OOK) modulation. In these RF modules, the carrier frequency is fully suppressed and consumes low battery power. Usually, the operating frequency range of RF module is 315 or 434 MHz. RF transmitter part has four pins: VCC, GND, data, and antenna. VCC and GND pins are connected to +5 V pins and GND pin, respectively, and the data pin is connected to digital input/output pin of Arduino. Antenna pin in the RF transmitter module can be connected to the antenna through a wire wound in the form of coil. RF transmitter transmits the data from Arduino to the receiver through the antenna. The receiver receives the data through the antenna and transmits it to the Arduino connected to it. This can be done with VirtualWire Library. It is a library used for communication between two Arduino using RF module. The library consists of several functions to configure the modules, transmit the data with the transmitter module, and receive the data using receiver module. Arduino UNO connected with RF transmitter module is shown in Fig. 10.15.

Fig. 10.15
figure 15

Arduino UNO with RF transmitter module. (Source: Electronics Hub)

RF receiver part has four pins: VCC, GND, data, and antenna. VCC and GND pins are connected to 3.3 V pin and GND, respectively, and the data pin is connected to digital input/output pin of Arduino. Antenna pin in the RF receiver module is connected to the antenna through a wire wound in the form of coil. In this work, Arduino board can communicate with each other using RF transmitter and receiver module. RF receiver module connected to Arduino is shown in Fig. 10.16.

Fig. 10.16
figure 16

Arduino UNO with RF receiver module. (Source: Electronics Hub)

10.2.8 LED

In this work, three LEDs are used. Green, red, and orange LEDs are used to indicate the values of sensor low, moderate, and high condition.

10.2.9 LCD

It is an electronic display module that uses liquid crystal to display the values. 16 × 2 LCD is used in this work for displaying the measured values. The LCD is interfaced with Arduino to display the measured values. LCD is connected to Arduino by connecting RS pin of LCD to pin 12 of Arduino. Operating voltage of LCD is 4.7–5.3 V.

10.3 Results and Discussion

The source code is written in C language in Arduino IDE environment. The sensors are tested individually and integrated into a single whole system. The code was uploaded to Arduino through the USB connected to the Arduino. The Arduino has several analog input pins that help to get analog input from sensors. These signals have multiple range of input; Arduino scales it to the range of 0–255.

In this work, multiple sensors can communicate with the Arduino through a single serial port of Arduino expanded using serial port expander. The sensors must be changed to UART mode before it gets connected to the expander board. The sensor readings are monitored continuously, and the results are displayed on a serial port monitor. The steps to interface sensor with Arduino are given below.

10.3.1 Steps for Connection

  1. 1.

    Ezo_uart_lib, a zip folder was downloaded from GitHub to the computer.

  2. 2.

    Arduino IDE is opened in the computer.

  3. 3.

    In the IDE, select sketch --→ include library--→add ZIP library-→Ezo_uart_lib folder.

  4. 4.

    Code Serial_port_expander_example is copied on to IDE work panel.

  5. 5.

    Compile and upload the Serial_port_expander_example code on to Arduino UNO.

  6. 6.

    Channel communication can be done with serial monitor.

  7. 7.

    Serial monitor is opened in the Arduino UNO, go to Tools ---→Serial Monitor.

  8. 8.

    Baud rate is set to the rate of 9600.

  9. 9.

    Readings of sensors are displayed on the serial monitor.

In this work, two water samples are tested from two different water sources. Water samples from normal tap water and industrial water are taken. pH value of wastewater from industry is in the range of 6.5–8.5 and that of tap water in the range of 6.5–9.5. The temperature of tap water is around 13 °C. The ultrasonic sensor outputs are obtained and checked by varying the water level in the sample water tank. The output of ultrasonic sensor is measured in centimeters. The ultrasonic sensor output is monitored continuously during each and every fixed duration of time, so that sudden changes in the level of water can be found, which indicate that there is a leakage of water in the tank. The flow sensor reads the amount of water flowing through the storage tank. The flow sensor is fixed to the small pump outlet, so that the sample outputs are taken from the sensor. The sample outputs are collected and displayed in the serial port monitor.

The arrangement of flow and ultrasonic sensor is shown in Fig. 10.17, and the serial monitor that displays the sensor values is shown in Fig. 10.18. The snapshot of the proposed system for water quantity and quality monitoring is shown in Fig. 10.19. Tables 10.1 and 10.2 list the sensors with the specifications that are interfaced with Arduino.

Fig. 10.17
figure 17

Arrangement of ultrasonic and flow sensor

Fig. 10.18
figure 18

Output of sensor displayed in the serial monitor of Arduino

Fig. 10.19
figure 19

Experimental setup of water quality and quantity monitoring system

Table 10.1 Sensors interfaced with Arduino
Table 10.2 Summary of the sensor with the specification used in the proposed work

10.4 Conclusion and Future Scope

IoT-based water quality and quantity monitoring system is proposed in this work. In this work, quality and quantity of water are monitored using various sensors with web server through the Internet. Parameters are displayed on the web page so any variations from the certain level can be monitored easily. Monitoring of turbidity, pH, and temperature of water is done using various sensors with unique advantage of utilizing existing GSM network. The flow and level of the water in the storage tank is also monitored continuously. The system can monitor water quality and quantity automatically with less human intervention. So, the water testing with the proposed method is likely to be cheaper, easier, and flexible. This system can also be extended to monitor other parameters of water by including different sensors and also by using the appropriate resources. This work can also be extended to monitor pollution in air and soil contamination also. Using the embedded devices with suitable sensors for monitoring, different environmental parameters make the environment to be pollution free. To implement this, it is necessary to deploy the suitable sensors for measuring various parameters and doing analysis. By deploying different sensor devices, it can interact with other gadgets through the network for monitoring the environmental parameters. This method of collecting the data and performing analysis on the data will be made available to the authority through the Wi-Fi.