Water Logged: Detect Running Faucets with Edge ML and Cellular IoT

A certain motel chain may leave the light on for you as a matter of safety and comfort, but if anyone were to leave the faucet on for you, well, that would just be weird. While leaving the water running is not something that is done on purpose, it does happen all the time for a number of reasons. The elderly, those with memory impairments, and children can often forget to turn off a faucet after they are finished with it. For a typical faucet, this wastes two gallons of water per minute according to the US EPA. That can really add up on water bills and may even result in costly water damage from an overflowing sink.

Unfortunately, the only way to recognize that the water has been left running is to directly take notice of it. So if someone accidentally leaves the water on, then leaves their home, it could be a while before that happens. Engineer Naveen Kumar saw this as an opportunity for improvement. Using Edge Impulse, he designed and built a machine learning-powered device that can recognize when a faucet is running. When this happens, an alert can be sent to the cloud or a smartphone via a cellular network to make the situation known, wherever the forgetful hand washer happens to be at the time.

The hardware components of the device

To make it simple to install this device, Kumar decided to use audio signals to detect the sound of running water. By going this route, no modifications need to be made to the existing plumbing. An Arduino Nano 33 BLE was chosen for the build because it has ample processing power to run the highly-optimized machine learning models produced by Edge Impulse, and the onboard microphone is the only sensor that is needed. A Blues Wireless Notecard was included in the design to give the device the capability to wirelessly communicate over cellular networks.

Before constructing the intelligent algorithm, sample data was needed to train it.  Kumar used the Edge Impulse CLI to link the Arduino to his Edge Impulse Studio account, then recorded audio data with the onboard microphone. In total, he recorded fifteen minutes of audio data from two different classes — the faucet running and background sounds. This data was automatically assigned labels and uploaded to Edge Impulse. Before attempting a widespread deployment of a running water detector, a larger, more diverse dataset would need to be collected, however this small dataset should be just fine for a proof of concept.

Collecting sample data with the Edge Impulse CLI

Having finished up the prerequisites, the stage was set to build the machine learning model. An audio MFE preprocessing block was first added to extract time and frequency features from the signal. By extracting the most important features from the data up front, any step in the pipeline that follows it will benefit from having less computationally-intensive work to do. These features were fed into a neural network classifier that interprets the incoming signal and learns whether it represents running water or normal background noise.

After taking a look at the Feature Explorer tool, it was clear that there was good separation between data from each class. So with confidence that there was a good signal in the data, Kumar started the model training process with the click of a button. After a brief wait for the training to complete, a confusion matrix was presented to help understand how well the model was performing.  An average classification accuracy of better than 99% was observed. To further validate this excellent result in a more stringent way, the model testing tool was used. This tool runs classifications on data that was held out from the training process. This validation showed that the model classified more than 91% of samples correctly. That is more than sufficient for a prototype, so Kumar moved on to deploy the model to the physical hardware.

The completed audio classification impulse

By running the model directly on the hardware, privacy issues that could arise from recording audio in your home are alleviated — no sensor data ever needs to leave the device. Deployment was an easy process. Kumar chose to deploy the model as a downloadable Arduino library using the deployment tool in Edge Impulse Studio. This contains everything that is needed to run inferences against the model, and can be imported to Arduino IDE just like any other library. It also offers the flexibility to include your own logic in the Arduino sketch.

Kumar needed this flexibility, because he also wanted to add code to control wireless communications with the Blues Wireless Notecard, and to send notifications over that wireless network when running water was detected. As a finishing touch, the hardware was placed inside of a plastic case that can be mounted on the wall next to a sink. The final product met Kumar’s goal of being simple to install and use. One need only to stick the self-contained box to the wall next to a sink and plug it in. From there, it will send alerts to a smartphone via Twilio when the water is left running.

The completed proof of concept device

With a bit more work to miniaturize the device, perhaps building it into a smart plug form factor, and designing a simple interface to configure the phone number that the notifications are sent to, this running water detector could have success commercially. That is quite incredible considering that a device like this can be built in an afternoon with the help of Edge Impulse Studio. Did this running water detector inspire you to finally build the idea that has been in your head for months?  If so, take a peek at the project write-up for some tips that will get you up and running in no time. If you need a little inspiration to get started, perhaps you could begin with a running water detector that automatically manipulates the faucet handle to shut off the flow of water.


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

Subscribe

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

Subscribe to our newsletter