Automatic Water Meter Reading with a Webcam
I have previously tried to read the water meter using a phototransistor and a IR diode, but have not managed to get it hundred percent stable.
Instead, I have now used a little more technically challenging solution but it works perfect.
I use a webcam and calculates one of the dialers position and movements.
The solution consist of:
A webcam with USB connection.
Two white LEDs. Used to have a constant uniform illumination of the meter.
A Raspberry Pi with some image processing software.
I have adapted this opensource software to my camera and this specific application.
The Raspberry Pi is managing to read and process approx 10 frames per second. I have defined eight zones in the image and keeps track of when these zones goes from light to dark when the dial passes. My dial makes one revolution per liter of water so it will be a resolution of 0.125 liters.
Attached is avideo clip and a couple of pictures, that shows how it looks like in practice. (The video clip is a bit old an taken when I only had four zones defined)
ThinkPad last edited by
Very cool! Especially the video that shows how it works!
I was aware of this project: http://zil.olammi.iki.fi/sw/dialEye/ but that seems quite complicated in setting up for a Linux noob. But your project seems a lot easier.
Can you please share your code? I am very enthusiastic to try this on my meter And what is inside the black box on top? Only webcam + LED's or some other circuitry?
cool project! why do you need to monitor the water meter?
I'm currently working on version 2.0 of the Water Meter Reader. The new version will be based on an OpenWrt device called Dragino and will have a nice looking web GUI for setup and maintenance.
Of course can I share my Raspberry Pi code. Attached you will find a copy of it. It has dependencies to:
The sdl library can you install the ordinary way with apt-get. But libmosquitto you have to install following these steps:
sudo apt-key add mosquitto-repo.gpg.key
apt-cache search mosquitto
apt-get install libmosquitto-dev
It also has a dependency to an external MQTT-broker at 192.168.0.23. You probably have to adapt that to something else or remove it if you dont want to publish the values via MQTT.
In the structure REGION the sizes and positions of the "Hit areas" are defined.
Two main reasons to monitor the water meter
- Leakage monitoring. The system can detect very small leakages and send notifications to my mobile.
- I'm interested in my water consumption. The values are logged and displayed in my home automation system.
@gol fair enough... Thanks!
ThinkPad last edited by
@gol Thanks. Sounds quite complicated, but i will have a look at it.
As a home automation controller i use Domoticz so i will probably have to convert it to HTTP GET-requests (http://domoticz.com/wiki/Domoticz_API/JSON_URL's). I don't have any knowledge about MQTT haha.
Very nice! Gives a nice resolution in used water. I'm wondering in defining the leakage, are you measuring the time it takes to get from region to region?
What software is used for the recognition? I'm currently busy with face recognition using opencv.
The output from the water meter reader, published in MQTT, are:
- Average flow last minute (liter/minute)
- Average flow last 10 minute (liter/10minutes)
- Consumption last drain (liter). The number of liters between the last two times with no consumption.
- Total consumption (liter)
The leakage monitoring is very simple. It uses only value 1 and checks if the flow > 0 during a couple of minutes. The accepted duration is very low at night and when nobody is at home.
All info about the used software you will find earlier in this thread.
Ahh clear. I know the dependencies mentioned. Will later take a look at the software, did not had enough time to download the package to take a look into it
pawwnu last edited by pawwnu
First of all, this is an excellent job. I love to see that kind of achivements. I am trying to use your code in my university project. I'm going to be analysing how exactly does my heat pump work. I always loved technology as such, however I'm not so good at programming.
Here comes my question. Would you be so kind and give me some more info on how to setup Mosquitto broker to work with your code?
Thanks in advance and once again congratulations on your idea as well as execution.
fje last edited by fje
Thanks for sharing! I managed to get your code running, altered it to log to a round robin database instead of through Mosquitto, and I am now graphing my water usage!
I have posted a description of my setup and code (Swedish I'm afraid, google translate is your friend - everyone except @gol ) to http://blog.m.nu/vattenmatning-med-raspberry-pi-och-webkamera/
Thanks and Regards,
Rasmus7700 last edited by
Wow that project seems awesome - exactly what i need to my openHab installation
@gol could you please post some more information regarding the setup?
A Former User last edited by
I love this idea of this project. I wanted to see if you made any changes to your code since the last upload? I want to develop something like this for myself and I'm willing to contribute if you had the code uploaded to github or something like that.
Matti Orrberg last edited by Matti Orrberg
There are several solutions for this kind of water reading but all are lacking something for my needs.
I've been seeking for a solution which would combine best parts of different projects:
- accuracy of 0,125 litres by reading only 1 liter dial with 8 trigger points. Easy and this data would be sufficient combined with time stamps.
- ESP32-CAM as camera and server running the OCR would be a lot cheaper than raspberry system. Usually someone building these have the server and really I wouldn't have any other needs for the Raspberry.
- Also this could be integrated ESPHome etc.? So it would be out of the box type design for ie. Home Assistant...
- Possibility to define any IP web camera as source
But I'm not any good at programming or coding... I'm not even sure if I describe my wishes correctly, please pardon me.
Would I find someone interested enough to combine these three solutions?
TL;DR water meter solution development request:
- 1 liter dial OCR with 8 trigger points
- ESP to server and server OCR software (prefer Ubuntu systems)
- MQTT publish and/or Home assistant compatibility via ESPhome or similar systems?
Willing to throw in a coffee/beer or two for this matter...