Towards an IoT-Based System for Monitoring of Pipeline Leakage in Clean Water Distribution Networks 1 Towards an IoT-Based System for Monitoring of Pipeline Leakage in Clean Water Distribution Networks Tuyen Phong Truong1, Giang Thanh Nguyen1 and Luong Thanh Vo1 1Can Tho University, Can Tho City, Vietnam Abstract Climate change-causing drought is wreaking havoc in the Mekong Delta, but water usage and management are still inefficient, resulting in a loss rate of more than 20%. This research is being carried out to contribute to lowering the rate of water loss and improving the management of the clean water supply. This suggested system makes use of wireless sensor networks, the Internet of Things, and cloud database storage technologies. The readings collected by the flow and water pressure sensors at the sensor nodes installed along the plumbing system will be relayed to the gateway through the LoRa wireless communication network. The gateway will aggregate the collected data, upload it to a cloud database, and then analyze it to detect and give an appropriate alert for water leaks if any occur. An application for the Android smartphone assists in visually monitoring recorded data. The research results have been evaluated in operation, with initial results fulfilling the key requirements. Keywords: Internet of Things, leaking pipe, LoRa technology, smart cities, water distribution systems. Received on 10 December 2021, accepted on 31 March 2022, published on 31 March 2022 Copyright © 2022 Tuyen Phong Truong et al., licensed to EAI. This is an open access article distributed under the terms of the Creative Commons Attribution license, which permits unlimited use, distribution and reproduction in any medium so long as the original work is properly cited. doi: 10.4108/eetsc.v6i17.230 1. Introduction Currently, the COVID-19 pandemic has threatened cities and communities, endangering not only public health but also the economy and social fabric, directly affecting community health and quality of life, particularly the lack of clean water for daily life and production [1]. According to a 2015 global report, one in every ten people (roughly 2.1 billion people worldwide) lacks access to safe drinking water. According to Interreg Central Europe [2-3], we lose 25–50% of clean water every day, causing many people to live in water scarcity. The shortage of clean water in daily life and production in Vietnam, like in other affluent countries, is becoming increasingly significant. The average rate of revenue loss and loss of clean water in 2015 for the whole country was 30%, equivalent to about 5.5 billion VND per day [4]. Saigon Water Supply Corporation (Sawaco) has also created an online water supply management system with network management, incident management, and real-time updates. However, the system is still underutilized and the cost is still prohibitively high. Even though it has been in use since May 2019, the drainage rate in the first nine months of 2020 at Thu Duc Water Supply Joint Stock Company, where the system was installed, is still 12.85 percent [5]. A wide number of research studies regarding water leakage in water distribution networks have been carried out. Some of them have been focused on developing algorithms for detecting and estimating leakage models and integrating them into a water distribution network hydraulic model. Consequently, a lot of CAD software has been proposed to detect the location and compute the leakage quantities of water for solving the network leakage flows [6–10]. On the other hand, there are some others focused on pipeline leak detection technology based on optical fiber sensing technology and a proposed algorithm for pipeline leakage detection [11]. The technique may use the frequency domain to discover leak spots by obtaining time-domain signal characteristics of pipeline leakage. There were also some research projects on building a leak detector for clean water supply pipes using the negative correlation method, which is based on the detection and measurement of the time deviation of the sound emitted from the leak point when handling the audio signal recorded at the two ends of the pipeline segment. However, because they are only zoning the problem area, they cannot pinpoint the precise location of the leak. In addition, the device has been unable to survey a long pipeline because the sensor is insensitive due to EAI Endorsed Transactions on Smart Cities Research Article EAI Endorsed Transactions on Smart Cities 10 2021 - 03 2022 | Volume 6 | Issue 17 | e5 mailto:https://creativecommons.org/licenses/by/4.0/ mailto:https://creativecommons.org/licenses/by/4.0/ T. P. Truong, G. T. Nguyen and L. T. Vo 2 environmental noise, and it cannot be connected to multiple sensors at the same time [12–13]. As a result, there are still some concerns that need to be addressed in current research, such as high cost due to having to spend money to deliver messages if using a mobile network, and centralized processing on a circuit board. These restrictions have implications in terms of geographical location, such as the inability to set up the system over a vast area and the difficulty of expanding it. Therefore, the goal is to deploy the system over a large area using a wireless sensor network. Because the measurement system is simple to set up and inexpensive, wireless sensor nodes are used to easily expand the system. The organization of this article is presented as follows. Section 1 provides an overview of the current situation, causes, and solutions for water leaks in clean water supply systems. Section 2 discusses the design and implementation of the proposed pipeline leakage monitoring system, which includes the hardware architecture and embedded software. Section 3 presents experiments to evaluate the operation of the water leak monitoring system on the main pipeline before Section 4 concludes the article by presenting a summary of the results and the research plans. 2. System design 2.1. System overview Figure 1. The overview of the pipeline leakage monitoring system A LoRa wireless sensor network, depicted in Figure 1, consists of one gateway and three sensor nodes that exchange data using long-distance, ultra-low power LoRa technology. The gateway, which acts as a link between the LoRa network and the Internet, is in charge of data aggregation and real-time data updates to the Firebase Cloud. An Android smartphone application allows for easy visual monitoring of recorded values obtained from sensors for detecting water pipeline leaks. In Figure 2, the STM32 Blue Pill [14], which equips an STM32F103C8T6, an ARM 32-bit Cortex M3 architecture with high-performance and almost all the standard peripheral interfaces for reading sensor values, is used for control circuitry at the sensor node. The sensor node is designed to receive data from sensors using common peripheral communication standards such as UART, I2C, SPI, and so on, and then transmit data to the gateway using LoRa wireless transmission, specifically the LoRa Ra-02 module. The LoRa Ra 02 module is a small LoRa transceiver that uses a Semtech SX1278 chip and operates at 430–435 MHz. It has low energy consumption and a transmission range of around 15 kilometers [15–17]. The gateway used here is a Raspberry Pi 4, compact and high- performing [18]. The gateway in this case is a Raspberry Pi 4, which is small but powerful in performance. This is an embedded computer with an Ethernet connector and Wi-Fi for Internet connectivity that runs the operating system on a memory card for easy control programming. In addition, as can be seen in Figure 2, the Raspberry Pi 4 also supports a standard SPI interface connected to the Ra-02 module to facilitate data transmission between the LoRa wireless sensor network and data upload to the cloud database. Figure 2. System block diagram and communication between the gateway and a sensor node 2.2. Hardware design to extend the lifetime of the proposed system The sensor node powered by a battery will be buried deep alongside the clean water supply pipeline system in the actual application conditions, so the power supply for the sensor node to operate is a concern. The investigation of energy-saving modes to determine the best method for assisting the sensor node in consuming less energy. The sensor node's hardware has two designs for this purpose: stop mode (the microcontroller power-down mode) and power off (see Figure 3). The sensor node reduces power consumption while in use with energy-saving modes. As a result, a device capable of waking the microcontroller from sleep mode is required. The RTC DS3231 module, with two built-in alarms, a 32 kHz temperature-compensated crystal oscillator, and a backup battery to maintain accurate timekeeping when the device's power source is disconnected, is one of the suitable choices [19]. The power-off method is an effective solution to save maximum energy for the sensor node. For this reason, LP5907, Texas Instruments' linear voltage regulator with low noise, output current up to 250 mA, high resistance to power fluctuations [20], is used to manage the power supply for the microcontroller and LoRa module. EAI Endorsed Transactions on Smart Cities 10 2021 - 03 2022 | Volume 6 | Issue 17 | e5 Towards an IoT-Based System for Monitoring of Pipeline Leakage in Clean Water Distribution Networks 3 Figure 3. Block diagram of two power-saving modes for sensor node Under normal conditions, the data from 10 sensor readings will be stored at the sensor node before being sent to the gateway to save energy. Unless a leak is detected, the data will be sent immediately. As a result, EEPROM was used to ensure that the data stored at the sensor node is not lost when the power is turned off. CAT24C128 is a 128KB serial EEPROM that is internally organized into 16384 words and is divided into 256 pages with 64 bytes each for the write buffer, as well as write protection and error correction code [21]. Figure 4. The electronic circuit board of the sensor node was inside a protective plastic box to avoid damage Flow and pressure sensors are integral parts of the system to monitor parameters that aid in leak detection of water supply lines (see Figure 4). The Hall YF-05 DN20 measures water flow rates from 1 to 30 l/min. In the presence of flowing water, it generates square pulses that create a magnetic field to activate the Hall sensor [22]. A pressure sensor (SKU237545) generates an output signal when the applied force with 12-bit resolution, a pressure range of 0–200 PSI, an accuracy of 1.5%, and a response time of fewer than 2 milliseconds [23]. A GPS (Global Positioning System) module is installed to locate the location of the system's sensor nodes. Because the sensor nodes are fixed, the board is designed with an extra slot for connecting the GPS, allowing the GPS module to be reused for multiple sensor nodes. The Venus638FLPx-L GPS module operates in tracking mode by default, automatically responding to data at a frequency of 1 Hz with a compact design and high accuracy [24]. Figure 5. The electronic circuit board of the gateway 2.3. Embedded software development In this system, a LoRa gateway (see Figure 5) is often deployed at a high position, and it can thus establish direct communication with all sensor nodes. The gateway of the LoRa network is set up to operate in two phases. Phase 1 performs the construction of the routing table and establishes the sensor network by sending a broadcast message and waiting to receive a response message, which is the identifier, from the sensor nodes operating in the coverage area. Phase 2 is the process of collecting data from sensor nodes, processing data, uploading data to the cloud, and warning when there is a pipeline leak. The program on the gateway needs to perform phase 1 periodically to update the active sensor nodes after executing phase 2 n times. Most of the time, the sensor network will collect data to satisfy the requirements of monitoring and warning, but still, ensure optimal connections in the network to help the system operate stably and long-term. Figure 6. Flow chart of process on the sensor node EAI Endorsed Transactions on Smart Cities 10 2021 - 03 2022 | Volume 6 | Issue 17 | e5 T. P. Truong, G. T. Nguyen and L. T. Vo 4 Because the sensor node is permanently installed, the packet is divided into two types: a coordinate packet that contains the longitude and latitude of the sensor node's installation position, and a data packet that contains the sensor node's data. Only when the gateway requests it is this packet sent. The data packet contains flow, pressure, date, and time values, as well as time synchronization between the gateway and the sensor node, which aids in the detection of water pipe leaks. During the system's operation, this packet is always sent to the gateway. To save energy, the sensor node only works for a set amount of time and then goes into the power-saving mode for the remainder of the time. The flow chart in Figure 6 explains this in detail. 2.4. Android App development An application for Android smartphones has been developed to allow users to easily access and visually observe the system installation location, flow, and pressure parameters at each node, which are displayed on the map. When a leak in the pipeline is detected, users are notified. The graphs are plotted separately for each flow or pressure parameter per node and are automatically refreshed based on a real-time updated Firebase database. Details can be seen in Figure 7. Figure 7. Measurement data is uploaded to a Cloud database and updated to the application on an Android smartphone in real-time 3. Experiment 3.1. Compare power saving modes According to the experimental results, the power consumption in run mode is 0.1476 Wh. Stop mode consumes 0.0145 Wh, which is 10 times less than run mode, and power off consumes 0.0126 Wh, which is 11 times less. In stop mode, the system consumes 0.0145 Wh, which is 10 times less than in run mode, and its power off mode consumes 0.0126 Wh, which is 11 times less. A 3.7V-2200 mAh Li-ion battery is used to power the sensor node, which reads data from sensors every 2 minutes. The data is aggregated and sent to the gateway after every 255 reads. As a result, the system's operating time is approximately 7.5 days. Table 1 summarizes the power consumption of the STM32F103C8T6 in experimental measurements. Table 1. Power consumption of microcontroller Working stages Working time (T) Electricity consumption Stop mode Power off Reading sensor 30 s 0.0041 Wh 0.0041 Wh Saving energy 530 s 0.0020 Wh 0.0001 Wh Sending data 40 s 0.0084 Wh 0.0084 Wh 3.2. Experiment to detect water leakage Figure 8. A basic experimental study on leakage for the water supply pipe In Figure 8, the water supply pipe system in the experiment consisted of two branches, which were fitted with two sensor nodes each at the two ends of the pipeline, about 5 meters apart. Branch three was not fitted with sensor nodes and was fitted with a drain valve at the end of each branch. When there is a water leak in the pipeline at branch 1, the water flow at node 1 is greater than the flow at node 2. The pressure deviation at node 1 does not change much depending on the water supply flow into the pipeline, and the pressure at node 2 decreases (see Cases 1 and 3 in Table2). If the water valve at the end of branch 1 is opened, the pressure at node 2 will decrease due to dynamic pressure, and the flow at node 2 will be less than at node 1 (see Cases 1, 2, and 4 in Table2). When the water valve at branch 3 is opened, the pressure in node 1 and node 2 decreases together, but the flow does not change. EAI Endorsed Transactions on Smart Cities 10 2021 - 03 2022 | Volume 6 | Issue 17 | e5 Towards an IoT-Based System for Monitoring of Pipeline Leakage in Clean Water Distribution Networks 5 After completing pipe installation and supplying water to the pipes (assuming they are not leaking), calculate the "leak threshold" value using sensor references and consider the difference in received values at the beginning and end of each pipe. The gateway will issue an alert when the next data collection shows the calculated value exceeding the threshold. From case 1, the first collected values are viewed when the system is installed and the leakage threshold is determined as follows: PThreshold = 1.02989, FThreshold = 0. Suppose the pipeline is leaking in case 3, P = 1.063736 > PThreshold and F = 33 > FThreshold, combine the two conditions on the gateway that raises the alarm. Table 2. Experimental measurements Case studies Node 1 Node 2 Flow (ml/min) Pressure (bar) Flow (ml/min) Pressure (bar) 1. Not leak and not open valve 0 1.181209 0 0.151319 0 1.147363 0 0.148901 0 1.142527 0 0.146484 2. Not leak and open valve 100 1.533901 100 0.158571 100 1.526923 100 0.158571 133 1.188462 133 0.134396 3. Leaking and not open valve 33 1.198132 0 0.134396 33 1.181209 0 0.129560 50 1.173956 0 0.127143 4. Leaking and open valve 133 1.181209 116 0.134396 90 1.176374 73 0.137650 83 1.546264 66 0.156154 4. Conclusion This paper presents the design and implementation of a leak detection system for clean water supply pipelines. The system established a LoRa wireless sensor network that allows the detection and warning when there is a leak in the water supply pipeline over a large area. An application on smartphones helps users to visually observe the flow rate and pressure parameters based on applying a real-time database service. In the experimental measurement, a LoRa network consisting of 4 sensor nodes and 1 gateway was deployed that collects and uploads data to the cloud in real- time through an Internet connection. For electrical energy saving, power supply control circuitry and embedded programs were developed. Experimental results show that the proposed hardware and software design help enhance system performance. For future work, we plan to improve the quality of the sensors used for more accurate and reliable measurements, continue to improve the hardware and software, and conduct more experiments and calibrations on the actual water supply pipeline system. References [1] Kenth Hvid Nielse. Using Smart Water in Cities. New Straits Timers. October 22 2020. https://www.nst.com.my/opinion/columnists/2020/10/6345 04/using-smart-water-cities (accessed on 9 December 2021). [2] Lam Hong. Warning about the risk of water shortage. Nhan Dan (People) newspaper. September 27 2019. https://nhandan.com.vn/tin-tuc-the-gioi/bao-dong-nguy-co- thieu-nuoc-sinh-hoat-369008/ (accessed on 9 December 2021). [3] Anh Vu. Thirst threatens the world. Ministry of Natural Resources and Environment (Vietnam). June 21 2019. http://dwrm.gov.vn/index.php?language=vi&nv=news&op =Nhin-ra-The-gioi/Con-khat-de-doa-toan-cau-8216 (accessed on 9 December 2021). [4] Decision No. 2147/QD-TTg of the Prime Minister (Vietnam). National program to combat loss of revenue and clean water by 2025. https://vanban.chinhphu.vn/default.aspx?pageid=27160&d ocid=97899 (accessed on 30 March 2022). [5] Quang Dinh. Water supply with smart technology in the Industry 4.0 era. September 20 2020. Tuoi Tre news. https://tuoitre.vn/cap-nuoc-bang-cong-nghe-thong-minh- thoi-40-20200926104940329.htm (accessed on 9 December 2021). [6] M. Tesfaye, S. Narain, H. K. Muye. Modeling of Water Distribution System for Reducing of Leakage. Journal of Civil & Environmental Engineering.2020; vol. 10: 6. [7] J. Almandoz, E. Cabrera, F. Arregui, E. Cabrera, R. Cobacho. Leakage Assessment through Water Distribution Network Simulation. J. Water Resour. Plan. Manag. 2005; vol. 131:6. [8] M. Maskit and A. Ostfeld. Multi-objective operation- leakage optimization and calibration of water distribution systems. Water (Switzerland). 2021; vol. 13:14. [9] K. B. Adedeji, Y. Hamam, B. T. Abe, A. M. Abu-Mahfouz. Leakage detection and estimation algorithm for loss reduction in water piping networks. Water (Switzerland). 2017; vol. 9:21. [10] A. Adamuscin, J. Golej, M. Panik. The challenge for the development of Smart City Concept in Bratislava based on examples of smart cities of Vienna and Amsterdam. EAI Endorsed Transactions on Smart Cities. 2016; Volume 1, Issue 1. [11] Kazeem B. Adedeji, Yskandar Hamam, Bolanle T. Abe, Adnan M. Abu-Mahfouz. Pipeline Leak Detection Technology Based on Distributed Optical Fiber Acoustic Sensing System. IEEE Access. 2020; vol. 8:21. [12] Pengxiang Technology. Acoustic emission monitoring of pipeline leakage. February 03 2014. https://www.ndttech.net/en/Solutions/Acoustic_Emission_t esting/299.html (accessed on 9 December 2021). [13] Tran Viet Chau. Research and manufacture leak detector on clean water supply pipeline using negative correlation method on PC platform. Project report at Can Tho University, Vietnam. 2017. [14] STMicroelectronics. STM32F103x8-Medium-density performance line ARM-based 32-bit MCU. EAI Endorsed Transactions on Smart Cities 10 2021 - 03 2022 | Volume 6 | Issue 17 | e5 T. P. Truong, G. T. Nguyen and L. T. Vo 6 https://www.st.com/resource/en/datasheet/stm32f103c8.pdf (accessed on 9 December 2021). [15] LoRa Alliance. LoRa and LoRaWAN: A technical overview.https://lora- developers.semtech.com/uploads/documents/files/LoRa_an d_LoRaWAN-A_Tech_Overview-Downloadable.pdf (accessed on 30 March 2022). [16] Semtech Corporation. SX1276/77/78/79 - 137 MHz to 1020 MHz Low Power Long Range Transceiver Rev. 7, 2020. [17] H. Mroue, G. Andrieux, E. M. Cruz, G. Rouyer. Evaluation of LPWAN technology for Smart City. EAI Endorsed Transactions on Smart Cities. 2017; Volume 2, Issue 6. [18] Raspberry Pi Trading Ltd. BCM2711 ARM Peripherals. https://datasheets.raspberrypi.com/bcm2711/bcm2711- peripherals.pdf (accessed on 30 March 2022). [19] Maxim Integrated. Extremely Accurate I2C-Integrated RTC/TCXO/Crystal, Rev 10. https://datasheets.maximintegrated.com/en/ds/DS3231.pdf (accessed on 30 March 2022). [20] Texas Instruments. LP590 250-mA, Ultra-Low-Noise, Low-IQ LDO, Snvs798o –April 2012–Revised June 2020. [21] ON Semiconductor, EEPROM Serial 128-Kb I2C CAT24C128 Rev. 17 https://www.onsemi.com/pdf/datasheet/cat24c128-d.pdf (accessed on 30 March 2022). [22] Seeed Technology Co. Ltd. Water Flow Sensor. https://wiki.seeedstudio.com/Water-Flow-Sensor/ (accessed on 30 March 2022). [23] Rev Robotics, “Analog Pressure Sensor Data Sheet”, Rev.11,2015, https://www.revrobotics.com/content/docs/REV-11-1107- DS.pdf (accessed on 9 December 2021). [24] SkyTraq Technology, Inc. Venus838FLPx 50Hz -165dBm Low-Power GPS Module. https://www.skytraq.com.tw/homesite/Venus838FLPx_PB _v1.pdf (accessed on 9 December 2021). EAI Endorsed Transactions on Smart Cities 10 2021 - 03 2022 | Volume 6 | Issue 17 | e5