Heating Oil Tank Sensor Integration Project

Hi everyone, I wanted to share my recent project of integrating a heating oil tank sensor into my Home Assistant setup. This was a fun and educational experience, and I hope it can inspire others to tackle similar projects!

Background
Our house relies on a heating oil tank for warmth during the colder months. Keeping track of the oil level manually can be a hassle, especially when planning for deliveries. I decided to automate this process to ensure I never run out of oil and to monitor consumption more efficiently.

The Setup
I chose to use an ESPHome-powered ESP8266 module paired with a waterproof ultrasonic distance sensor. The sensor is mounted in a fuel cap, which I had lying around, to avoid drilling into the tank. This setup keeps all electronics safely outside while only the sensor is in contact with the oil.

Implementation

  1. Sensor Placement: I carefully positioned the sensor in the fuel cap to ensure accurate readings. The ESP8266 handles the data processing and communicates with Home Assistant via MQTT.
  2. ESPHome Configuration: I wrote a custom ESPHome code to measure the distance from the top of the tank to the oil level. This data is then converted into liters using a polynomial calibration based on the tank’s dimensions.
  3. Integration with Home Assistant: The sensor data is fed into Home Assistant, creating a custom sensor for oil level in liters. I also set up an input number for manual oil deliveries and a button to update the sensor with the new level.

Challenges and Solutions

  • Calibration: Accurately converting the distance readings into liters required extensive testing and calibration. I created a detailed lookup table to ensure precise measurements.
  • Data Persistence: To prevent data loss during power outages, I stored the last recorded oil level in the ESP’s EEPROM.
  • Dashboard Integration: While the energy dashboard doesn’t support liters, I converted the readings to kWh (1 liter = 10 kWh) for consistency with other energy metrics.

Results and Benefits
This project has been a huge success! I can now monitor my oil levels remotely and receive alerts when it’s time for a delivery. The integration with the energy dashboard provides a comprehensive view of our energy consumption, helping us make informed decisions.

Tips for Others

  • Plan Carefully: Ensure accurate measurements and proper placement of the sensor for reliable readings.
  • Calibration is Key: Spend time fine-tuning your sensor to avoid discrepancies in data.
  • Backup Data: Implement data storage solutions to maintain continuity during outages.

I’m thrilled with how this project turned out and look forward to sharing more DIY solutions in the future. Happy tinkering! :blush: