
Heating Oil And Usage



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 an 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.
How AI On The Edge Can Help?
Most oil tanks have analog meters which are not easy to read by machines. Moreover, adding a sensor in an existing tank to measure fuel level is expensive as it needs some poking and prodding, and oil tanks are typically old and there is a risk to damage the tank. I am looking for a cost effective and non-invasive way to read the analog meter in real time.
Edge Impulse And Visual Regression
Data Capture
With any ML project, data capture is the most important step. To capture data from our heating oil tank is a time consuming task as the meter moves very slow, and I may need to wait for a month to capture all the different readings. So I designed and 3D printed an analog meter similar to a real heating oil tank meter, to capture data.
Custom 3D printed analog meter

Creating Impulse
Creating an “Impulse” in Edge Impulse, is basically creating your ML model.

Deploy

Deployment
#include <sony-analog-meter_inferencing.h>
Connect To AWS IoT
Once I get the model prediction, I connect to a cellular network and send data to AWS IoT Core over MQTT. Before you can connect to AWS IoT Core, you need to:- Create a policy
- Create and download certificates ( Root CA, certificate and private key )
- Attach certificates to the created policy
- Create a Thing
- Attach policy to the Thing
register.py
program, change the variables, and run the program. This will create the AWS resources for you, and download the certificates and private key under the certs
folder. Now you need to copy those files to the SD card and insert it into the Spresense LTE board.

System Architecture


AWS IoT Rule

Data received by AWS IoT Core


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

Demo
Low-Powered Battery Operated

- Sony Spresense supports 156, 32 or 8 MHz clock frequency. I set clock mode to 32 MHz, as the Camera can work on it. And power consumption is almost half compared to 156 MHz.
- Stored AWS certificates in a header file rather than on the SD card. Typically it draws around 40mA for read/write operations, 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. The location is not going to change once it’s installed. Smart meter location is inserted from the app during device registration. This helps save battery power further.
- Reading data once every day. As the oil level is not going to decrease significantly every hour, it’s overkill to read the meter very frequently like every few minutes or hours. The smart meter wakes up every 24 hours, takes a picture, runs the inference to predict the reading, connects to the cellular network, and sends data to AWS IoT Core over MQTT. The whole process takes around 150 seconds. The rest of the time the device goes to deep sleep mode, drawing about 300 μA.

1100mAh With Clock 32MHz

1100mAh Clock 156MHz
Cawake × (Tawake / 3600) + Csleep × ((3600-Tawake) / 3600)
Assuming current draw is 75mA (32 MHz clock), with a 2500mAh battery, it will last about 55 days and with 115mA (156 MHz clock), it will last about 44 days.

Read this article for more information.
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 a secured connection or setting up the Truphone Sim card as I believe it’s very generic and common with any new development 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 an LED light turn on before taking the picture.