Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!

Monitoring Oil Tank Level with Computer Vision

Steve needed a way to keep track of his heating oil and computer vision turned out to be the perfect technology for the job.

Measuring the amount of liquid in a container is surprisingly non-trivial. If the liquid in question happens to be conductive, you can use a series of contact sensors. But those only tell you if the liquid is to the level where you’ve placed the sensors, which quite low-resolution. The good old-fashioned float gauge is a good alternative, though it comes with issues of its own. To electronically monitor the float gauge for his heating oil tank, Steve turned to Raspberry Pi and computer vision.

Steve points out that there are more practical solutions to this problem and that he tackled it as a “fun diversion,” but we don’t think he is giving himself enough credit. Some may call this over-engineered, but it is actually very sensible. It only requires a few affordable hardware components, provides very accurate readings, and doesn’t necessitate the modification of the oil tank. The tank in question holds heating oil and news outlets are predicting shortages this coming winter, so knowing how much oil one has on hand is going to be important.

Steve points out that there are more practical solutions to this problem and that he tackled it as a “fun diversion,” but we don’t think he is giving himself enough credit. Some may call this over-engineered, but it is actually very sensible. It only requires a few affordable hardware components, provides very accurate readings, and doesn’t necessitate the modification of the oil tank. The tank in question holds heating oil and news outlets are predicting shortages this coming winter, so knowing how much oil one has on hand is going to be important.This heating oil is similar to diesel and most people store it in a large tank in their homes (often in the basement). A traditional float gauge indicates the current oil level in the tank. Steve’s device consists of a Raspberry Pi Zero W and a Raspberry Pi Camera module. The camera points at the float gauge and the Raspberry Pi uses OpenCV computer vision software to analyze the video feed.

Steve’s OpenCV script looks at the float gauge and first detects the positions of the level markings on the tube. Those correspond to completely empty, one-quarter full, half full, three-quarters full, and completely full. The markings provide a visual scale for OpenCV to reference. The software also looks for the red float and creates a line centered between the top and bottom of the float. That line, relative to the scale markers, corresponds to the oil level. This provides a much more accurate reading than a person eyeballing the gauge and is even more accurate than many electronic gauges meant for this purpose—all for about $20 worth of hardware.

The Raspberry Pi can illuminate a strip of NeoPixel LEDs to reflect the current oil level or it can make the data available through various IoT and home automation platforms. Steve set it up with Home Assistant and with a custom web app that includes the video feed. It also has a REST API, which further expands the accessibility.

We love projects like this, because they demonstrate how practical and affordable “cutting edge” technology like computer vision can be.

Cameron Coward
Writer for Hackster News. Proud husband and dog dad. Maker and serial hobbyist. Check out my YouTube channel: Serial Hobbyism
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles