Build a Running Faucet Detector... Water You Waiting For?

We can all forget things from time to time which is perfectly normal, but as people grow older, or struggle through medical conditions like dementia, poor memory can become a real problem. Often when we think about the problems that occur in these situations, the big ones — like forgetting to take medications, or to eat regular meals — are what come to mind. But the more mundane, everyday tasks that are forgotten can also have a big impact on people’s lives. Consider turning off the faucet when you have finished with it, for example. There are dozens of opportunities for the elderly or infirmed to make this mistake in a typical day, and the result can be both costly and dangerous. According to the US EPA, leaving a faucet on for just five minutes wastes ten gallons of water. Further, if left unchecked, it could lead to water damage and a slipping hazard.

Prolific machine learning enthusiast Naveen Kumar has developed a solution that can detect when a faucet has been left on, and sound an alarm to bring attention to the situation. His proof of concept device includes a low-power development board running a machine learning algorithm that was designed and trained with Edge Impulse to detect the sound of a running faucet.

The unassembled components

Kumar chose the powerful NXP i.MX RT1010 Evaluation Kit with an Arm Cortex-M7 core CPU clocked at up to 500 MHz and 128 KB of RAM. The board comes standard with an onboard microphone that Kumar leveraged to capture audio from a faucet. The device also includes an NXP PCF85063AT-ARD real-time clock shield, an M5Stack Atom Lite (for Wi-Fi connectivity), a SSD1306 OLED display, and a passive buzzer. All of the modules connected to the expansion ports on the i.MX RT1010 board to produce a single compact, tidy unit.

The MCUXpresso Integrated Development Environment was used to develop the i.MX RT1010 firmware. The firmware included code to interact with the microphone, the OLED display, and the real-time clock. The logic controlling the overall operation of the device (i.e. capture an audio sample, classify it with a neural network, sound an alarm if appropriate) was also developed here. With the firmware in place, Kumar then turned to Edge Impulse to help him deal with the complexities of building and training a machine learning model

Uploading data to Edge Impulse

A new project was created within Edge Impulse, then a prebuilt dataset, which contained fifteen minutes of audio data was uploaded. The audio dataset consisted of two classes — a faucet running, and miscellaneous background noises. An impulse was then created to preprocess and classify this type of data. A Mel-frequency cepstral coefficient (MFCC) preprocessing block was selected to extract important features from the data, after which these features are passed into a learning block containing a neural network classifier. After tweaking the model parameters a bit, Kumar then trained the model with the previously uploaded audio dataset. Even with the small size of the training dataset, the model was found to achieve an accuracy of 89.3% in classifying the sound of a running faucet.

89.3% in classifying the sound of a running faucet

The model was then exported from Edge Impulse as a C++ library so that it could be imported into MCUXpresso IDE and deployed to the physical hardware. The completed device continually samples audio, displays model predictions on the OLED display, and sounds a buzzer if the faucet has been running for longer than a predetermined amount of time. Through the M5Stack Atom Lite, it is also possible to send an email alert, if desired.

As for future plans, Kumar hopes to create a larger training dataset to improve the classification accuracy of the device. He is also interested in experimenting with external microphones to determine if that may also improve performance. Take a peek at the full project write-up to get started building your own version of this setup.


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

Comments

Subscribe

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

Subscribe to our newsletter