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)

    Video Clip - Water Meter Reading

    watermeter1.jpg
    watermeter2.jpg



  • 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?


  • Hero Member

    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:

    • libsdl1.2-dev

    • libmosquitto-dev

    The sdl library can you install the ordinary way with apt-get. But libmosquitto you have to install following these steps:

    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.

    water-meter.tar.gz



  • @Moshe-Livne
    Two main reasons to monitor the water meter

    1. Leakage monitoring. The system can detect very small leakages and send notifications to my mobile.
    2. I'm interested in my water consumption. The values are logged and displayed in my home automation system.

  • Hero Member

    @gol fair enough... Thanks!



  • @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.


  • Plugin Developer

    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.



  • @John
    The output from the water meter reader, published in MQTT, are:

    1. Average flow last minute (liter/minute)
    2. Average flow last 10 minute (liter/10minutes)
    3. Consumption last drain (liter). The number of liters between the last two times with no consumption.
    4. 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.


  • Plugin Developer

    @gol

    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 ๐Ÿ˜‰



  • Hey
    @gol

    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.



  • @gol

    Hi!
    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,
    Jim, Linkรถping



  • Wow that project seems awesome - exactly what i need to my openHab installation ๐Ÿ™‚
    @gol could you please post some more information regarding the setup? ๐Ÿ™‚



  • Hey @gol

    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.

    Throdne



  • 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:

    1. https://github.com/ecsfang/WaterMeter
    • 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.
    1. https://github.com/jomjol/water-meter-measurement-system
    • 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...
    1. https://olammi.iki.fi/sw/dialEye/
    • 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...

    Regards, Matti


Log in to reply
 

Suggested Topics

  • 8
  • 1
  • 1
  • 7
  • 3
  • 44

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts