Published On 2022-07-10

Smart Oil Meter Using Visual Regression

Using Sony Spresence & EI, turns analog oil tank meter into digital, realtime update on the app help delivery company optimize operation.

Heating Oil And Usage

Heating oil is mainly used for space heating. Some homes and residential commercial buildings also use heating oil to heat water but in much smaller amounts than what they use for space heating. Because cold weather affects heating demand, most heating oil use occurs during the heating season—October through March.

In the winter of 2020–2021, about 5.3 million households in the United States used heating oil (distillate fuel oil) as their main space heating fuel, and about 82% of those households were in the U.S. Northeast.

Heating oil is also used in many countries in Europe. Source

Operational Inefficiencies

Usually heating oil companies deliver the oil in a truck. Many heating oil companies monitor your usage to determine when you will need oil delivery again. These calculations are performed using degree days and a K-factor. The degree days calculation adds the high and low temperatures on a given day, divides it by two, and subtracts 65 from the quotient. This number is added to your home’s K-factor.

The K-factor determines “degree days per gallon” (think something similar to “miles per gallon” here) to estimate how quickly you use heating oil. Over time, our heating oil company can settle on a relatively stable K-factor for your home. We can then calculate your next delivery using your unique K-factor and our own calculations.

But this calculation is not accurate all the time. Family can go on vacation resulting in less oil consumption or some relatives visiting during holiday season resulting in more oil consumption.

Okay, so what's the big deal ?

Extra cost and additional CO2 emission - If the delivery is done when tank is 3/4 full, it's a waste of money and extra emission of CO2 in the environment. Delivery during cold weather is expensive in terms of effort as well. It does not make sense to fill the tank when it's already 3/4 full.

No heat during cold - On the other hand, if consumption is high suddenly and tank empty, there would not be any oil to heat the house. This can be very challenging and life threatening as well.

With real time reading of oil tank, delivery company can schedule the delivery precisely when it's needed. This will eliminate unwanted visit to the resident reducing delivery cost and less CO2 emission.

How AI On The Edge Can Help?

Most of the oil tanks have analog meters which are not easy to read by machines. Moreover adding a sensor in the existing tank to measure fuel level is expensive as it needs some poking with oil tanks which are typically old and there is a risk to damage the tank.

I am looking for cost effective and non-invasive way to read the analog meter in real time.

Using visual regression, we can train a model to read analog meter and predict a scalar value between 0 to 100. This value is then sent to cloud using cellular connection.

System Architecture

Dashboard UI

Before we install and start consuming data from the smart device, we need to register the device on the app.

Once smart meter is installed and powered on, app start showing data on the dashboard.

Low-Powered Battery Operated

Another key aspect of this project is to run the smart meter on battery for several months before recharging. This is important as there may not be power source near the the heating oil tank.

Things considered to maximize the use of battery are

  • Sony Spresense supports 156, 32 or 8 MHz clock frequency. I set clock mode to 32 MHz as Camera can work on it. And power consumption is almost half compare to 156 MHz.

  • Stored AWS certificates in a header file rather on the SD card. Typically it draws around 40mA for read/write operation which is quite high compare to GNSS read (7mA).

  • Not reading GNSS to obtain GPS location of the smart meter as its location is static. Not going to change once installed. Smart meter location is inserted from the app during device registration. This helps save battery further.

  • Reading data once every day. As oil lever is not going to decrease significantly every hour, it's over killing to read the meter very frequently like every minutes or hours. Smart meter wakes up every 24 hours, take picture, run the inference to predict the reading, connect to cellular network and send data to AWS IoT core over MQTT. The whole process takes around 150 seconds. Rest of the time the device goes to deep sleep mode drawing about about 300 μA.

Based on my brief research, with clock 32MHz, average current draw was around 75mA with a spike to 213 mA when board connects to cellular network and send data to AWS. And total execution time was around 76 seconds.

With clock 156 MHz, average current draw was around 110 mA with one big spike to 264 mA and few spikes to between 150-200. We may consider average of 115 mA. Total execution time was 64 seconds compared to 76 seconds.

Hourly consumption is calculated as:

Cawake × (Tawake / 3600) + Csleep × ((3600-Tawake) / 3600)

Assuming current draw is 75 mA (32 MHz clock), with 2500mAh battery, it will last about 55 days and with 115 mA ( 156 MHz clock), it will last about 44 days.

But note, this is an estimate and actual battery life depends on lot of environmental factors such as temperature, qualify of the battery pack, how fast it discharge etc.

Challenges

Of course no project is without challenges. I am not going to discuss any technical challenges I faced to get the Sony Spresense working with LTE over secured connection or setting up the truphone sim card as I believe it's very generic and common with any new dev board we try for the first time. Other challenges to point out are

Different background of the image has huge impact on the performance of the regression model. So I decided to have a static background. This is a feasible option in production as well. Lighting is another aspect. Heating oil tanks are mostly located in the basement without any natural light. We should have LED light before taking the picture.

Leak & Anomaly Detection

As I am receiving readings from the board, we can run ML model on AWS to predict any abnormality such as too fast draining of oil which may indicate some leakage or provide some feedback to the customer to review the usage.

Demo Video

Checkout the full article on Hackster