Don’t Be a Drip: A TinyML-Based Solution for Acoustic Pipe Leak Detection

Water pipe leaks are perhaps one of the lesser recognized of the big problems that we face. Often out of sight, these leaks are easy to ignore, but the consequences of doing so are substantial. The average household in the US wastes nearly 10,000 gallons of water each year through pipe leaks, according to the Environmental Protection Agency. A full 10 percent of homes waste over three times that average amount annually. These leaks also extend beyond households to the larger pipelines that supply water to entire communities. Shockingly, it is common for leakage to exceed 50% of the total water distributed through these systems.

The cost of all of these leaks is huge, so there is a thriving market serving the need to detect and locate pipe leaks. This market reached a size of over 1.7 billion dollars by 2019, and is projected to top 2.3 billion dollars by 2027. Clearly, the cost of pipeline leaks will be large when they occur, but engineer Manivannan Sivan does not believe that finding the problems should also be so costly. So, he put his skills to work to develop a low-cost solution to the problem of pipe leak detection. He did so with an Arduino board and a machine learning model built with Edge Impulse.

Collecting data to train the model

One method to detect a leak is to listen to the sound of water flowing through a pipe. When the pipe is leaking, the sound of the flowing water will be changed. It is not easy to quantify those changes, however, so Sivan built a machine learning model to recognize these differences and classify them. For the hardware platform, he chose the Arduino Portenta H7 development kit. This board has a dual-core processor to power machine learning model inferences. An Arduino Portenta Vision Shield was also included in the build because it has onboard microphones that can be used to capture the audio that is required to detect leaks.

Having decided on a neural network to classify the audio samples, Sivan’s next task was to collect data to train the model. This was accomplished by affixing the device to a pipe, with the Vision Shield facing the pipe to collect the best audio possible. Then data was collected to represent three classes — no water flowing, normal water flow, and water leaking. To simulate a leak, he partially closed the tap to reduce water flow. Once the sample data was ready, it was uploaded to Edge Impulse studio so that Sivan could get down to work building a classifier.

Building a classification pipeline

The impulse he designed consisted first of a preprocessing step that transforms the audio data into spectrograms, then extracts the most important features. This serves to reduce the computational resources that are needed by the classifier, and also helps to improve classification accuracy. These features were fed into a convolutional neural network that translates them into a prediction of one of the three chosen classes.

The model was trained on the previously uploaded data, then checked for accuracy on a separate dataset. This test showed that the model had achieved 100% accuracy in classifying audio samples. You just cannot do any better than that, so Sivan moved forward with this model and deployed it directly to the Arduino board.

Validation of the classifier

Because both the Arduino Portenta H7 and the Portenta Vision Shield are fully supported by Edge Impulse, deployment was very simple. Selecting this board from the “Deployment” page built custom, downloadable firmware containing the full machine learning pipeline. After flashing the firmware to the board, Sivan was in business. The pipe leak detection system he envisioned had already become a reality. He tested the board out with some live classifications and found that it worked very well, living up to the 100% classification accuracy that had been found during testing.

Sivan’s project is a great example of how tools like Edge Impulse can make it simple to build very powerful devices on a tiny budget that would have been unthinkable just a few years ago. With a bit more data collection and testing, we hope to see this device deployed on a large scale, saving both water and money. If you do not want to wait until that time, you are in luck — Sivan has publicly released his Edge Impulse project, and you can read up on all the rest of the nitty-gritty details in the project’s documentation.

Want to see Edge Impulse in action? Schedule a demo today.


Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter