Nobody enjoys crawling into a dark cupboard once a month to squint at a gas meter by flashlight. Cian Gallagher got tired of the ritual under his stairs, so he handed the chore to a Raspberry Pi that now watches the dial around the clock and reads it for him.
The setup is refreshingly simple. A Raspberry Pi 4, a Camera Module 3, and a small LED light sit inside the meter cupboard. Every ten minutes a cron job snaps a photo, rotates it to fix the upside-down camera angle, crops down to just the digit window, timestamps it, and saves it locally. Over a few weeks that quiet routine piled up thousands of images, which became the training data for the whole system.
Those photos fed a YOLOv8 Nano object-detection model that Gallagher trained specifically for his meter. He hand-labeled more than 3,200 images one digit at a time so the network learned exactly how each numeral looks on that display. He also left a little padding around the crop instead of hugging the digits tightly, giving the model room to cope if someone bumps the cupboard door and nudges the camera. No constant recalibration required.
Reading eight digits in half a second
Once trained, the model gets exported to ONNX so it runs efficiently on the Pi, decoding each frame locally in roughly 300 to 500 milliseconds. The detector spots the individual digits, sorts them left to right, and assembles the full eight-digit reading. Reflections that produce phantom detections get filtered by dropping the least-confident predictions, and if too few digits show up the reading is thrown out rather than guessed. Two more sanity checks catch trouble: low-confidence results are flagged for review, and any reading that drops or jumps implausibly is discarded, since a gas meter should only ever tick upward. Clean readings are pushed to Home Assistant through its REST API, where they land in the Energy Dashboard and graph consumption automatically. On submission days the Pi even fills out Gas Networks Ireland's web form, handling the rotating form tokens and the provider's 14-day interval.
Build it yourself
You need less than you might think: a Raspberry Pi 4, a Camera Module 3, a scrap of LED strip for even lighting, and Python with the Ultralytics library for training. The tricky part is the dataset, not the wiring. Label a few thousand frames of your own meter, export to ONNX, and point the readings at whatever dashboard you like. Full write-up and code are on Hackster.io. Grab a Pi 4 and Camera Module 3 at circuit.rocks and turn a monthly chore into a one-time build.
Originally published on blog.circuit.rocks.
Top comments (0)