Water monitoring

Water monitoring

Conserving resources is an important topic and always worth pursuing. The current energy prices and inflation just add a higher monetary incentive for everyone to make more effort. I took this as a trigger to see if and how much water, especially warm water, I can save in my household. As with all improvement projects, you need to know your current baseline before you can measure any improvements.

The nice, but impractible solution

Ideally, I would want a continous measurement of my water usage, so every change can be tracked. The usual analog water meters are not ideal for this task, but it is not too complicated to set up an ESP32 with an ESPcam to digitize the meters. A little bit of machine learning to detect the numbers and the spinning wheel will give very precise readings throughout the whole day. Unfortunately, this setup is not practible as I would need four cameras for the four water meters (one for cold and hot in two rooms each) and the water meters are also a bit far from the next electricity outlets. A humid bathroom is also not ideal for electronics.

The simple solution

I actually don’t need measurements every few minutes to satisfy my curiosity and get a better understanding of my water usage. A longer interval of maybe a week would be fine, too. The day-to-day variation is large anyway (think of a dishwasher or the toilet on home office versus office days) and a week is probably a reasonable period to track changes in water usage.
This means I just need a handy interface to log the water meter readings manually. It takes a mere minute to work around the apartment with a smartphone, read all meters and enter the values.
So, I wrote a simple streamlit frontend to log water meter readings into InfluxDB. They are then visualized in Grafana.
Its dependencies make Streamlit a huge library for a simple web frontend and cause a unnecessarily large docker image … but it’s just so convenient and simple.

Data logging

You can find the code for the streamlit app and the dockerfile in this repo on my GitHub.

The ready-to-use docker image is also available on Docker Hub: water-monitoring @ Docker Hub. The configuration is done through environment variables.

The frontend is kept simple with input fields for date, time and the water meter readings. The last values are queried from the InfluxDB backend, so changes are reported already while entering the new values (green values next to the arrows).


The visualisation of the water usage was done, as for other projects, in Grafana. It’s convenient to have a whole bunch of dashboards in a single tool, so I can quickly look up what I want to know.

The dashboard breaks down the water meter readings by room and temperature. These absolute values are harder to interpret, though, and a more meaningful metric is the daily/weekly/monthly water usage. The differentiate() function in combination with a temporal groupby() is a simple way to calculate this automatically. Obviously, the differentiation can be only calculated from the second data point onwards. Therefore, the example below just shows two daily usage points but three water meter readings.

The complete dashboard is a bit more complicated than this example. It shows raw values in tables, different totals (combinations of meters) and break downs over different periods.

A success already

With the baseline in place, it’s time to reduce my water usage and see how much water and heating I can save. Even if I fail to save water, this project has already risen my awareness for water substantially.

A final note

If the header image seems sketchy that’s because it is. I let Stable Diffusion generate a “room full of water meters and pipes, photography” and this was a cutout of the best result among many others.