Reading The Water Meter In A Literal Sense With An ESP8266

In our info-obsessed culture, hackers are increasingly interested in ways to quantify the world around them. One popular project is to collect data about their home energy or water consumption to try and identify any trends or potential inefficiencies. For safety and potentially legal reasons, this usually has to be done in a minimally invasive way that doesn’t compromise the metering done by the utility provider. As you might expect, that often leads to some creative methods of data collection.

The latest solution comes courtesy of [Keilin Bickar], who’s using the ESP8266 and a serial TTL camera module to read the characters from the LCD of his water meter. With a 3D printed enclosure that doubles as a light source for the camera, the finished device perches on top of the water meter and sends the current reading to HomeAssistant via MQTT without any permanent wiring or mounting.

Of course, the ESP8266 is not a platform we generally see performing optical character recognition. Some clever programming was required to get the Wemos D1 Mini Lite to reliably read the numbers from the meter without having to push the task to a more computationally powerful device such as a Raspberry Pi. The process starts with a 160×120 JPEG image provided by a VC0706 camera module, which is then processed with the JPEGDecoder library. The top and bottom of the image are discarded, and the center band is isolated into blocks that correspond with the position of each digit on the display.

Within each block, the code checks an array of predetermined points to see if the corresponding pixel is black or not. In theory this allows detecting all the digits between 0 and 9, though [Keilin] says there were still the occasional false readings due to inherent instabilities in the camera and mounting. But with a few iterations to the code and the aid of a Python testing program that allowed him to validate the impact of changes to the algorithm, he was able to greatly improve the detection accuracy. He says it also helps that the nature of the data allows for some basic sanity checks;  for example the number only ever goes up, and only by a relatively small amount each time.

This method might not allow the per-second sampling required to pull off the impressive (if slightly creepy) water usage data mining we saw recently, but as long as you’re not after very high resolution data this is an elegant and creative way to pull useful data from your existing utility meter.

15 thoughts on “Reading The Water Meter In A Literal Sense With An ESP8266

  1. That’s very neat. I had also been thinking a camera was the way to read the meter but didn’t think esp8266 was
    Up to the task- I was obviously wrong-

    In my place the meter is in the ground so I would need to add a system to clear away the red backs

  2. This is a project I am eager to tackle one way or another. I couple of years ago I had an outdoor pipe begin to leak which yielded a $2000 water bill. The utility had a policy that reduced this (thank goodness), but ever since, I have been wishing for a way to monitor and log my water flow. I could have a threshold set to alert me if daily flow was above some limit or if flow persisted longer than some time period — or something. If I can’t find a way to hack and monitor (read only mind you) the wireless telemetry, this would be an interesting idea.

  3. My city change ours out for radio meters. I’m not sure there is still a display, since it’s leaked, since it was installed, and always underwater. My bill isn’t usually high, so the leak is on the street side. Reported it, never fixed, last time I checked. Wish they would though, easier to shut off the water at the meter, if I need to do any plumbing work.

    I was really hoping the article was going to about reading a wireless meter (well, there wires, power I’d guess, which is why I never reach into the water). Still pretty cool, but have to wonder what the meter reader would do with it? They’d have to remove it, do you think they’d replace it, keep it, or reported as suspicious, and have the bomb squad out to take a look?

    1. Take a look. The wireless meter they installed on mine has a nice LCD display with more information than the old gear driven analog thing ever had. It does time multiplex (show one thing, then the next), so one snapshot could never harvest all the data. One thing it does have is a very nice and finely resolved instantaneous flow readout, which would be ideal to read for my purposes.

  4. Badger meter offers a customer porthole to the customer water usage. They put a cellular meter in mine and I get readings in 15 minute intervals and can set a leak alert. Best of all, it was included when they changed the meter out. I had a 3gph leak and I was notified in 4 hours of the leak start.

  5. I’ve said this before here, but i could’ve used this from 10 to 2 years ago. I actually looked a lot for a way to OCR with ESP8266, but didn’t find anything i could use.

    Now i don’t need to check the meter so often and it’s so much easier to access, that i don’t really have a need for this.

    Very nice project.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.