Making analog gas and water meters smart
Tags: automated, tools, mqtt, tasmota
Published: 2023-12-12 22:19:57

---
title: Making analog gas and water meters smart
published: true
date: 2023-12-12 20:03:11 UTC
tags: automated,tools,MQTT,Tasmota
canonical_url: 
---

💶

The following article contains ref links. If you buy something through this link, I get a small commission for it. Your price does not change and helps me to continue running this blog. All corresponding links are marked with the emoji on the left.

## Why make smart?
 ![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/12/making_analog-gas-and-water-meters-smart_banner-2.jpeg)

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.

⚠️

It is important to note that this variant should be legally compliant. In the case of variants with induction proximity sensors and/or reed contacts, the supplier can quickly accuse you of tampering with the watch. If a camera is used to read out the data, the argument is likely to be quite weak.

## 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.

![Making analog gas and water meters smart](https://m.media-amazon.com/images/I/71VvHEwXIEL.jpg)

This costs just under €22.90 in a 2-pack at Amazon at the time of writing: [https://amzn.to/3R0GHHJ](https://amzn.to/3R0GHHJ?ref=blog.disane.dev)💶, a cheap [Micro SD card](https://amzn.to/46ejXZ1?ref=blog.disane.dev)💶(16GB is more than enough here) and a micro USB power supply/cable for the power.

After that, we need software that can read the analogue digits via AI and then digitize them. Here is the nice tool from [JomJol](https://github.com/jomjol?ref=blog.disane.dev), namely [AI-on-the-edge-device](https://github.com/jomjol/AI-on-the-edge-device?ref=blog.disane.dev).

[

Installation - AI on the Edge Device

 ![Making analog gas and water meters smart](https://jomjol.github.io/AI-on-the-edge-device-docs/img/favicon.ico)logo

 ![Making analog gas and water meters smart](https://jomjol.github.io/AI-on-the-edge-device-docs/img/main.jpg)
](https://jomjol.github.io/AI-on-the-edge-device-docs/Installation/?ref=blog.disane.dev)

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

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](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?ref=blog.disane.dev).

💡

Make sure that you use a data USB cable and not a charging cable! Charging cables usually have no data lines and are therefore unsuitable and only cause a lot of pain by not recognizing the controller.

[

AI on the Edge Device - Webinstaller

 ![Making analog gas and water meters smart](https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/icon/favicon.ico)Webinstaller

 ![Making analog gas and water meters smart](https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/icon/watermeter.svg)
](https://jomjol.github.io/AI-on-the-edge-device/?ref=blog.disane.dev)

Alternatively, you can also use the microcontroller [manually flashing](https://jomjol.github.io/AI-on-the-edge-device-docs/Installation/?ref=blog.disane.dev#manual-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 `AI-on-the-edge-device __remote-setup__ *.zip`

[

Releases - jomjol/AI-on-the-edge-device

Easy to use device for connecting "old" measuring units (water, power, gas, ...) to the digital world - jomjol/AI-on-the-edge-device

 ![Making analog gas and water meters smart](https://github.githubassets.com/assets/pinned-octocat-093da3e6fa40.svg)GitHubjomjol

 ![Making analog gas and water meters smart](https://opengraph.githubassets.com/66591d289406e2865585234577129d8ce2d815850f584b69c3b032c1564b1d95/jomjol/AI-on-the-edge-device)
](https://github.com/jomjol/AI-on-the-edge-device/releases?ref=blog.disane.dev)

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.

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/giphy-1.gif)

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

[

ESP32-CAM-MB for Pipersberg G4 RF1 c by BerHerJohLin

Housing for an ESP32-CAM-MB to read the meter reading of a Pipersberg G4 RF1 c gas meter and send it via MQTT Software: https://github.com/jomjol/AI-on-the-edge-device The individual parts are screwed together with 3mm screws, length 20 to 25mm. The housing is held to the meter by a magnet, for which...

 ![Making analog gas and water meters smart](https://cdn.thingiverse.com/site/img/favicons/favicon-192x192.png)Thingiverse

 ![Making analog gas and water meters smart](https://cdn.thingiverse.com/assets/6a/d1/e3/0c/d6/featured_preview_2021-04-07_16_56_02-Window.jpg)
](https://www.thingiverse.com/thing:4820301?ref=blog.disane.dev)

[

Water meter adapter (AI-on-the-edge) by klein0r

This is an alternative mounting solution for the "AI-on-the-edge" project. https://www.youtube.com/watch?v=mDIJEyElkAU

 ![Making analog gas and water meters smart](https://cdn.thingiverse.com/site/img/favicons/favicon-192x192.png)Thingiverse

 ![Making analog gas and water meters smart](https://cdn.thingiverse.com/assets/16/e6/ee/ee/89/featured_preview_Water-2.png)
](https://www.thingiverse.com/thing:5167976?ref=blog.disane.dev)

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.

💡

The device should now be positioned on the water and gas meter so that the camera has a clear view of it.

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](https://www.calumetphoto.de/magazin/was-du-ueber-polfilter-wissen-solltest?ref=blog.disane.dev). With my water meter there were also strong reflections, despite the darkened image and reduced flash intensity, but these were less disturbing there.

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-16.png)

**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.

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-18.png)

**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.

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-19.png)

**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.

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-20.png)

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:

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-21.png)

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:

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-22.png)

❗

Always adjust the type according to the counter type to be read, otherwise the entities will be created with the wrong units and may be converted incorrectly.

If the connection to the MQTT broker works, you should now see your digitized meter in the Home Assistant:

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-23.png)

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:

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/image-24.png)

![Making analog gas and water meters smart](https://blog.disane.dev/content/images/2023/11/giphy-2.gif)

## Conclusion

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:

## Stay up to date 🔥
<form data-members-form="signup">
            
            <div>
                <input id="email" data-members-email type="email" required="true" placeholder="Your email">
                <button style="color: #ffffff;" type="submit">
                    <span>Subscribe</span>
                    <span><svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewbox="0 0 24 24">
        <g stroke-linecap="round" stroke-width="2" fill="currentColor" stroke="none" stroke-linejoin="round">
            <g>
                <circle cx="4" cy="12" r="3"></circle>
                <circle cx="12" cy="12" r="3"></circle>
                <circle cx="20" cy="12" r="3"></circle>
            </g>
            <style data-cap="butt">
                .nc-loop-dots-4-24-icon-o{--animation-duration:0.8s}
                .nc-loop-dots-4-24-icon-o *{opacity:.4;transform:scale(.75);animation:nc-loop-dots-4-anim var(--animation-duration) infinite}
                .nc-loop-dots-4-24-icon-o :nth-child(1){transform-origin:4px 12px;animation-delay:-.3s;animation-delay:calc(var(--animation-duration)/-2.666)}
                .nc-loop-dots-4-24-icon-o :nth-child(2){transform-origin:12px 12px;animation-delay:-.15s;animation-delay:calc(var(--animation-duration)/-5.333)}
                .nc-loop-dots-4-24-icon-o :nth-child(3){transform-origin:20px 12px}
                @keyframes nc-loop-dots-4-anim{0%,100%{opacity:.4;transform:scale(.75)}50%{opacity:1;transform:scale(1)}}
            </style>
        </g>
    </svg></span>
                </button>
            </div>
            <div>
                Email sent! Check your inbox to complete your signup.
            </div>
            <div data-members-error></div>
        </form>

Life as a dev, father, gamer and tech enthusiast