How to read old meters using ESP32 and artificial intelligence
Learn how to turn analog water or electric meters into smart devices using ESPHome, ESP32-CAM, and local image recognition models.
Summary
- Local image processing with AI eliminates cloud dependencies and ensures absolute privacy for household data.
- Combining ESP32-CAM with ESPHome drastically lowers operational costs for medium-scale home automation setups.
- Mechanical adjustments to lighting and focus prevent reading errors caused by glare on the meter's glass cover.
- Optimizing the microcontroller's power consumption extends battery life in isolated wall-mounted installations.
- Integrating optical readings into Home Assistant enables automated alerts against leaks or electrical waste.
Why automate analog meters with computer vision?
Many homes and businesses still rely on old water and electricity meters, featuring mechanical pointers or numbered dials that require physical visits from utility readers. Replacing these units with modern digital versions is often expensive and bureaucratic, requiring official utility approval. A smart, low-cost alternative is to install a micro-camera in front of the existing analog display, allowing a tiny computer to do the heavy lifting of looking at the dial and translating its position into readable numbers for your automation system.
In practice, this means building a bridge between the physical analog world and your monitoring hub without breaking any official seals on the meter. This approach gains massive traction with the use of low-cost Wi-Fi camera boards, opening the door for large-scale energy efficiency projects. To ensure the system doesn't crash due to internet latency, all visual processing happens right on the chip, avoiding sending sensitive photos to external cloud servers.
Before diving in, keep in mind that measuring consumption accurately requires attention to basic physical details, a topic we touch upon when discussing how to calculate real server power consumption, where data sampling principles apply directly to residential utility clocks. When dealing with analog signal capture, preventing electrical interference and visual noise is the first step to ensuring your system doesn't invent numbers in the middle of the night due to an unwanted shadow.
Choosing the ideal hardware for local processing
The heart of an automated optical reading project is the ESP32-CAM microcontroller, a tiny and extremely cheap board combining a standard ESP32 chip with a two-megapixel OV2640 camera. The ESP32 is a 32-bit processor with wireless communication capabilities, widely used in IoT projects due to its low power consumption and ease of custom code deployment. However, it was never designed to run heavy facial recognition neural networks, requiring algorithms optimized for microcontrollers, known as TinyML.
The main limitation of this hardware is restricted RAM memory, forcing developers to downscale captured images to smaller resolutions, like 320x240 pixels, before applying any mathematical filters. Lowering the resolution speeds up processing and prevents the chip from crashing due to out-of-memory errors when handling raw photos straight from the optical sensor. Furthermore, ambient lighting around the meter directly influences the result, making it essential to use a small auxiliary LED controlled by an ESP32 pin to illuminate the display only during the photo snapshot moment.
Configuring ESPHome to capture and process images
ESPHome is a system that lets you configure ESP32-based boards using simple plain text YAML files, generating programming code automatically without requiring advanced C++ knowledge. To integrate artificial intelligence character recognition, we use custom components or built-in integrations focused on running image processing directly in the device's firmware. The configuration file sets how often the camera takes pictures, sensor exposure time, and how the gathered data is sent via MQTT protocol to your automation hub.
Below is a simplified YAML configuration snippet showing how to structure image capture and wireless network connection inside the ESPHome environment, ensuring the device remains stable for months without human intervention:
esphome: name: smart-meter friendly_name: Water Meter esp32: board: esp32camesp32_camera: name: Meter Camera resolution: QVGA jpeg_quality: 80 vertical_flip: true mirror: truewifi: ssid: