Main Content

OpenCV Oil Tank Gauge Reader with Home Assistant Integration

A non-invasive reader for heating oil tank gauges, based on Raspberry Pi, OpenCV, and Home Assistant.

Welcome to the OpenCV Tank Gauge Reader project. This project aims to provide the necessary elements to build a non-invasive fuel oil tank gauge reader using standard off-the-shelf parts and some easy 3D prints. With built-in Home Assistant integration, it’s easy to view the level of your tank from your smartphone, or receive notifications when your tank is low.

This project is the original work of Steve Richardson (, and is released under the MIT License. It’s intended to be useful, educational, and fun. However, there’s no warranty and no guarantee that you won’t run your oil tank dry, burn your house down, or upset your cat. If you build this project, that’s all on you.

- Based on Raspberry Pi Zero W and the official Raspberry Pi camera
- Computer vision detects position of the indicator relative to the scale markings to determine tank level
- NeoPixel RGB LED Display shows level readings and status at a glance, improving upon the original gauge
- Home Assistant integration allows creation of custom dashboard displays and automatic notifications when tank level is low
- HTML5/JS web app allows real-time camera preview and instant computer vision parameter tuning
- REST API allows custom integrations

This project uses a $5 Raspberry Pi with WiFi and a tiny video camera to “read” the oil tank gauge level, using basic computer vision techniques. It provides the level reading to Home Assistant, where the Home Assistant app can show the oil level on screen at a glance, from anywhere. Home Assistant can also be configured to generate push notifications or make voice assistant (e.g. Alexa) announcements if the oil level has fallen to a low level.

I did the project as a fun diversion, to build something cool, and to learn a bit more about OpenCV. I was also motivated by the predicted shortages of heating oil for the 2022-2023 winter, in order to keep closer watch of my tank levels.

Is this the best (or even a sensible) way to read the level of your oil tank? Not really. There are commercial gauges on the market, like the Smart Oil Gauge, which replace a classic float gauge with a distance sensor (optical or ultrasonic) to measure the distance from the top of the tank down to the oil. The downsides are usually high price ($150-$200 USD), and that they involve an invasive change to the fuel oil tank, which may be a challenge due to rental agreements or local regulations. Most of these solutions also lose the basic visual gauge functionality that a classic float gauge provides, and only provide an electronic reading via an app. They are also private cloud-based solutions, and may not provide an API to integrate with your home automation software of choice.”

Link to article