Why make smart?
It makes a lot of sense to make the old analog water and gas meters smart. You can record consumption almost to the minute, understand your consumption and thus optimize it more sensibly. Especially in times of sustainability, fuel prices and/or the general scarcity of water, it is important to take a holistic approach to the topic.
What do we need?
In general, we only need some software and hardware to begin with. The costs (per water or gas meter) are usually a maximum of €20-30, depending on where the parts are purchased.
First of all, we ideally need an ESP32 with cam. This is a microcontroller with an integrated camera.
This costs just under €22.90 in a 2-pack at Amazon at the time of writing: https://amzn.to/3R0GHHJ💶, a cheap Micro SD card💶(16GB is more than enough here) and a micro USB power supply/cable for the power.
The software takes a photo of the counter at a certain interval. An AI then aligns the image according to set marks and an OCR with AI then evaluates the numbers accordingly and digitizes them.
The installation is quite simple via the web installer. To do this, the microcontroller must be connected to your computer via USB and the corresponding UART driver must be installed. As a rule, the ESP32s all use the CP210x USB to UART Bridge.
Alternatively, you can also use the microcontroller manually flashing.
Integrating into your own WLAN
After the microcontroller has been flashed, it sets up its own WLAN access point to which you must connect. The SSID should be
AI-on-the-Edge. Then navigate to http://192.168.4.1 in the browser of your choice. Here you should now be greeted by the basic setup of the firmware.
The current release should be pulled from GitHub first, which we will need at this point so that the initial configuration ends up on the SD card. You will need a
This file is then uploaded to the page. It will then rattle around a bit and should then display the WLAN configuration page. You can then enter your WLAN data there.
After a reboot, the microcontroller is ready.
Positioning on the water or gas meter
I myself have a Pipersberg G4 RF1 c as a gas meter and a Pipersberg T30 as a water meter. I was able to find corresponding housings for both on Thingiverse. If you also have these meters installed, I can highly recommend these models:
Unfortunately, you will have to test whether they work for you.
Setting up the firmware and configuring the camera
After rebooting and connecting to your WLAN, you should find out the IP of the controller and open it in the browser. A setup dialog will then appear in which you have to configure the camera and create a few reference images for the AI.
How to do this is as follows (in my example, I'll show you using my water meter):
Create reference image
Pay particular attention here to good, but not too stark, lighting. If there are disturbing reflections, you may have to work with polar filter foils. With my water meter there were also strong reflections, despite the darkened image and reduced flash intensity, but these were less disturbing there.
Create alignment markers
These are significant points in the image so that the AI knows how to align the excluded image. It is best to use two opposite points.
Creation of the digital ROIs (region of interest)
The ROIs are basically your numbers on the counter. These must be marked and framed accordingly for the AI. It is important that you position them well in order to achieve good results. Initially, you will have to play and test a little here.
Creation of ROIs for analog meters
Some meter types also have smaller round clocks in addition to the normal meters, which in this case can also be read in analog form. This tends to be the case with water meters, for example. How many of these you want to display as ROIs depends on how easy they are to recognize and how accurate you want your reading to be. In my case, I am satisfied if the meter reads accurately to 10l.
After this, the initial configuration is complete and the microcontroller should restart. After that, the entire setup is already complete and it now starts to photograph and digitize the meter at intervals.
The first measurements arrive
If everything went well, the first measurements should now also arrive. You can see the readings on the start page:
But that's actually only half the story. We have now digitized the data, but it would be smarter if we could send it to another system. The software offers interfaces to various systems for this purpose. These include MQTT (requires a broker) or InfluxDB 1/2. I opted for MQTT because there is also a Home Assistant Discovery here. If you have integrated your MQTT broker in Home Assistant, the device is automatically recognized and entities are created for it.
To do this, you can simply enter your MQTT data in the configuration:
If the connection to the MQTT broker works, you should now see your digitized meter in the Home Assistant:
Ideally, you can also integrate the meter(s) directly into the energy dashboard of Home Assistant and then have a very good traceability of your consumption habits:
With the above steps, you have now successfully digitized your analogue Stone Age meters and can now run nice evaluations in Home Assistant or Grafana (etc.) and understand and adjust your consumption behaviour.
In principle, reading an electricity meter also works in this way. If your electricity meter is already a modern measuring device, I would recommend using an infrared head for reading. This is more accurate and may also be able to read the feed-in of a solar system.
I will write another article on this in the future. Just sign up without obligation and you'll stay up to date: