Water Leakage detection system with tinyML framework

CASE STUDY SNAPSHOT

Customer : OEM on industrial equipment
Size : 51-200
Project vertical : Industrial
Challenge : To monitor and prevent leakage in water distribution system
Solution : Design and develop a Water Leakage detection system with tinyML framework
Services Availed :  Embedded ML development, Edge Analytics, Electronics product development services
Tools and Technologies :
  • MCU: ST Micro STM32L4R5
  • Framework: TinyML, One-Class Support Vector Machine, TensorFlow
  • Programming Language: C
  • Compiler: GCC

INTRODUCTION

Embien works with various industrial OEMs helping them design and develop numerous equipment. For one of them, we helped develop and manufacture electromagnetic flowmeters. The customer wanted to explore the smart city initiative where the technological trends were being utilized to better the quality of human life and optimize resource utilization. For that, the customer wanted to implement a water leakage detection system, by which the water distribution network had to be monitored at the local level.

CHALLENGE

There were two primary challenges in the system – price and usability. Since the system was targeted for local water distribution, the number of systems needed was huge. Having a computationally powerful system or a continuous subscription model for cloud-based connectivity was ruled out. The users would be local government workers who were not tech savvy and would need a simple mechanism to indicate potential leakage. Embien worked on the problem, identified the solution, and implemented the same via low-cost prototyping successfully.

SOLUTION

There are few methods to detect leakages in water distribution networks, of which Embien's team zeroed in on two approaches - Demand Pattern-Based detection and Off-Peak Demand-Based detection method.

Demand pattern-based method:

This method relies on analyzing the demand pattern within the water distribution network. By studying variations in water consumption over specific time intervals, anomalies or irregularities can be identified. Sudden deviations from the expected demand pattern may indicate the presence of leaks or other issues within the network. This approach leverages historical data and statistical analysis to detect abnormal consumption patterns that may signal the occurrence of leaks.

The behavior of flow systems can vary widely, from steady to unsteady laminar flow. Steady laminar flow maintains a constant fluid velocity over time, characterized by a consistent and predictable pattern. Conversely, unsteady laminar flow introduces fluctuations in velocity, following specific sequences or patterns. Regardless of the flow type, accurate measurement and monitoring of flow rate are essential for ensuring optimal system performance. Over a 24-hour period, data is collected at regular intervals to capture the nuances of flow behavior. Importantly, only normal data, free from leaks or anomalies, was utilized to train predictive models.

An autoencoder TensorFlow algorithm was employed to train the data and identify anomalies occurring within regular patterns. The diagram below captures the overall mechanism.



Demand pattern-based leakage detection​

The EPANET software was used to build a fundamental pipeline system during development and perform simulations. This model was converted into TensorFlow lite and ran in STM32 based tinyML framework with a memory consumption of about 15.27kB of RAM and 819.04kB of Flash.

Off-peak demand-based method

This method focuses on periods of lower water demand, such as nighttime when overall consumption tends to decrease. During these off-peak hours, the background noise in the water distribution system is reduced, making it easier to detect minor variations. Monitoring and analyzing water flow and pressure during less demand times can reveal subtle changes that might signify leaks. This approach capitalizes on the quieter periods to enhance the sensitivity of leak detection systems, making it possible to identify even minor anomalies that may not be apparent during high-demand hours.

In the off-peak demand-based method, the One-Class Support Vector Machine (SVM) machine learning algorithm was employed to train the data and identify leaks. The high-level block diagram of the Off-peak demand-based method is captured below.



Off-peak demand pattern-based leakage detection​

During development, the WNTR python package was used to build a fundamental pipeline system and perform simulation. This model was converted into C header and ran on tinyML framework on STM32 with memory consumption of 2.39kB for RAM and 26.2kB for Flash.

System Design

Embien's hardware design team identified STM32L4R5 for the development of the Water Leakage detection system. The data from flowmeter was acquired locally over the RS485 based Modbus protocol. The system had LED and buzzer to indicate if any potential leakage was detected. Embien's ML engineers acquired the data during both demand times as well as the off-peak demand times. Collected over 3 months at multiple locations with dedicated data loggers, the quantum of data was quite high system. Our ML team then fine-tuned the data by filtering out noises and then trained both the models. The trained data was then deployed on to the TinyML model in the STM32.

System operation

The water flow data input from the system was first validated along with basic filtering and pre-processing. Based on the flow level, the system detected if the distribution was on or off. If it was on, the Demand pattern-based method was activated. If the algorithm detected leakage, the buzzer as well as LED indications were on periodically. If the flow was below a threshold, the Off-peak demand-based method was activated, and similar indications shown on potential leakage detection. The output from the detection algorithms were also suitably processed and filtered before the indications were shown in the Water Leakage detection system.

Embien provided a few prototypes with the said algorithms and helped the customer to identify leakage in the water distribution system.

BENEFITS

Embien’s embedded machine learning expertise helped build the Water Leakage detection system for the customer with the following advantages.

  • STM32 microcontrollers enable real-time monitoring of water flow and pressure, allowing leaks to be detected promptly. 
  • By processing data locally on the STM32 microcontroller, the cost associated with transmitting data to the cloud was avoided by further reducing operation expenses.
  • Early detection helped prevent water loss, minimize damage to infrastructure, and reduce water wastage.
  • Multiple flow meters were supported to help interface the system with devices of any make enabling wider adoption.

CONCLUSION

While leakages in water distribution system through pipelines are the major issue faced across the globe, inspections by human resources to find leakage are difficult practically and not effective. This system detected the leak as soon as any damage is made to the pipelines due to several factors such as the pipe’s age, improper installation, and natural disasters. The use of AI technologies enhanced the efficiency and accuracy of Water Leakage detection system, enabling early identification and proactive management of water losses. Embien is proud to be associated in such an environmentally conscious project helping humankind save precious water!

Looking for a trusted partner for your medical device engineering in compliance with regulatory requirements?
Avail our our Turnkey Product development services and comply with IEC 62304 and IEC 60601-1