← All projects
TU/eIntelligent Interactive Products (IIP) · Individual project

Intelligent Water Monitor

A bathroom device that uses a microphone and a humidity and temperature sensor, plus machine learning, to recognise which water-using activity is running and estimate household water consumption.

The device sits in a bathroom and listens to its surroundings. A trained model recognises what is happening (nothing in use, a running faucet, a running shower or a flushing toilet) and the device shows its estimates, including the total monthly use, on a small OLED screen.

It is non-invasive: nothing is attached to the plumbing. The aim is to make everyday water use visible, so people can understand their habits and find ways to use less.

  • ESP32
  • Machine learning
  • Linear SVC
  • FFT audio features
  • Processing & Weka4P
  • 3D printing

The idea

Domestic water use is hard to understand: a monthly bill says little about how showering, running a tap or flushing a toilet add up. This project is a non-invasive bathroom device that estimates water consumption using environmental sensing and machine learning, and shows the results on a small OLED screen to raise awareness and encourage more sustainable habits.

The idea grew out of a societal issue I was exploring in another course, Scenarios for a Net Zero TU/e Campus (4CBLW007): reducing water waste in campus buildings. Campus-wide figures are published on the TU/e website, but good data on actual usage is missing. A device like this could give much more granular insight, such as which areas use the most water or when demand peaks, to support better-informed sustainability initiatives.

How it works

A Heltec ESP32 V3 microcontroller reads two sensor modules: an AHT21B temperature and humidity sensor over I2C, and a MAX4466 microphone through an analogue pin. I wired and soldered the components on a prototyping board, then modelled and 3D printed a simple housing to enclose the electronics and give the device a more professional finish. For now it connects to a laptop for power and to run training and classification in Processing.

Teaching the device

The learning goal is to recognise what is happening in the bathroom from sensor data, in four classes: nothing running, faucet running, shower running and toilet flushing. The input is the temperature, the humidity and the energy in a set of frequency bands from the microphone, and the output is one of the four states.

  • Sampling: the microphone runs at 8,820 Hz, a trade-off between a wide frequency range (up to 4,410 Hz) and light processing. Temperature and humidity are read at just 2 Hz, because they change slowly.
  • Serial bandwidth: to stream the high-rate audio live to Processing, I raised the serial baud rate from 115,200 to 921,600.
  • Pre-processing: raw readings are min/max normalised in the Arduino IDE, then a fast Fourier transform (ezFFT library, 1025 bins) turns the audio into frequency features.
  • Data: supervised training on labelled data, with 1,340 samples collected in only about three minutes of recording.
  • Model: a multiclass linear support vector classifier (LSVC), trained with the Weka4P library in Processing. Testing different cost values showed accuracy levelling off at about 85% from C = 16, so I chose C = 16 as a low value that still performs well.
  • Post-processing: a voting filter picks the most common of the last 100 predictions, which stops the output flickering between classes because of sensor noise, at the price of a small delay.

Results

  • 84.63% out-of-sample accuracy, evaluated with 5-fold cross validation.
  • "No utilities running" had the best recall (0.934), as expected: silence is easier to recognise than telling faucet, shower and toilet flow apart.
  • "Toilet flushing" had the highest precision (0.970), probably because a flush has such a distinctive sound.

Challenges and changes

Sensor choice caused an unexpected setback. I first added an MPU6050 accelerometer, running an FFT on its x, y and z axes, to capture more training data. In the first rounds of data collection it showed no noticeable features, because running bathroom utilities create little low-frequency vibration. I removed it and relied more on the microphone, which turned out to be a good decision: it let me focus on the remaining sensors and freed up serial bandwidth for the high-rate microphone readings.

Finding a concept was hard too. Unfamiliar with where machine learning can be applied meaningfully, I struggled to find an idea that connected with my values and suited the course. The water-waste problem from my other course finally gave it direction.

The Weka4P library in Processing was another hurdle: its syntax made it unclear how to experiment on my own. After playing with the library and reading up on it I had an 'oh, that's it?' moment, and trying different C values turned out to be easy.

Limits and next steps

  • It works well in the environment it was trained in when background noise is limited, but performs worse in busier settings. More training data from hectic environments could improve this.
  • It cannot yet recognise several activities at once, such as a shower and a faucet running together.
  • Estimates could improve with extra classes for different flow rates of each utility, though that would make classification harder and might lower accuracy.
  • The device still needs a laptop for power, training and classification.

What I learnt

Before this course I had never used machine learning in a project, and I lumped machine learning, deep learning and AI together, which made the topic feel daunting. Seeing how simple the mathematics behind a basic classifier is, and how easily a model can be trained and tuned, took away the black-box feeling and gave me the confidence to apply and interpret machine learning methods.

I expect to use LSVC classifiers in future projects, especially where manual thresholding is impractical or not enough, and I want to explore a wider range of algorithms and understand their strengths and limits.

Skills learnt & applied

LearntNew to me on this project4
  • Machine learning fundamentalsLearnt how machine learning, deep learning and AI relate, and how simple the maths behind a basic classifier is.
  • Linear SVC classification (Weka4P)Trained a multiclass classifier in Processing and tuned the C value to balance accuracy and simplicity.
  • Evaluating a classifierJudged the model with 5-fold cross validation, a confusion matrix, precision and recall.
  • Prediction smoothingAdded a voting filter over the last 100 predictions to stabilise the output.
AppliedExisting skills put to work6
  • Audio feature extraction (FFT)Turned microphone data into frequency-band features with a fast Fourier transform.
  • Supervised data collectionCollected and labelled 1,340 samples for four classes and normalised the raw sensor data.
  • Embedded electronicsWired a Heltec ESP32 V3 with an I2C temperature and humidity sensor and an analogue microphone on a soldered board.
  • Serial communication & samplingChose sampling rates and raised the baud rate to 921,600 to stream audio live.
  • 3D modelling & printingModelled and printed a housing for the electronics.
  • Problem solving with dataTested an accelerometer, saw it added nothing, and reworked the model around the microphone.