WiFi Oil Tank Monitor

by Itrium in Circuits > Sensors

12808 Views, 70 Favorites, 0 Comments

WiFi Oil Tank Monitor

front.png

There are several ways to check how much fuel is left in the heating oil tank. The simplest way is to use a dipstick, very accurate but not much fun on a cold winter’s day. Some tanks are fitted with a sight tube, again giving a direct indication of oil level but the tube yellows with age making reading difficult. Worse still, they can be a cause of oil leaks if they are not isolated. Another type of gauge uses a float which drives a dial. Not particularly accurate and the mechanism can seize up over time.

Those with deep pockets can buy a remote sensor which can be viewed inside the house. A battery driven sensor, usually ultrasonic, transmits the oil depth to a receiver in the house. A stand-alone mains driven receiver may be used to view the oil level or the receiver may be connected to the internet for remote monitoring.
What is needed is a battery driven WiFi connected sensor that can monitor the tank for years at a time and send email reminders when the oil level gets low. Such a device is described in this Instructable. A sensor measures the oil depth by timing how long it takes for light to reflect back from the oil surface. Every few hours an ESP8266 module polls the sensor and transmits the data to the internet. The free ThingSpeak service is used to display the oil level and send a reminder email when the oil level is low.

Supplies

The main components used in this project are listed below. The most expensive item is the depth sensor, a VL53L1X module which can be found online for about $6. Be careful not to select the previous generation VL53L0X, although cheaper, it has inferior performance and requires different software. The other key item is the ESP8266 module. The versions with onboard voltage regulators and USB interface are certainly easier to use but at a premium of higher standby current, not ideal for battery operation. Instead, the basic ESP-07 module is used with the option of an external antenna for extra range.

The components used in this project are:

  • AA battery holder
  • VL53L1X ranging module
  • BAT43 Shottky diode
  • 2N2222 transistor or similar
  • 100nF capacitor
  • 2 x 5k resistors
  • 1 x 1k resistor
  • 2 x 470 Ohm resistors
  • FT232RL serial adapter module
  • AA size Lithium Thionyl Chloride Battery
  • ESP-07 microcontroller module
  • Sundries, wire, box etc.

Choice of Sensor.

histogram.png
vl53l1x-2.png

Ultrasonic sensors are generally used for oil level measurement both commercially and in DIY projects. The readily available ultrasonic HC-SR04 or the newer HS-100 are often used in homemade monitors at a cost of about $1 or so. They worked fine on the bench but gave random readings when pointed down the oil tank vent pipe to locate the oil surface. This was probably due to reflections from the different surfaces in the steel tank, a plastic tank may work better. As an alternative, a VL53L1X Time of Flight optical sensor was tried instead. The readings from the tank were much more stable and so this type of sensor was pursued as the alternative.
The data sheet for the VL53L1X gives information about the resolution of this sensor under differing measurement conditions, see the picture. Using a sampling time of 200ms gives a resolution of a few mm. No doubt the data sheet numbers where taken under the best possible laboratory conditions and so the sensor was given a quick test to check the resolution. The sensor was positioned over the oil tank vent pipe and a few thousand readings logged using a timing budget of 200 ms. A distribution plot of the readings in the tank confirms that this sensor can measure the oil level with a resolution of about +/- 2mm.
Over longer time period, there is a daily trend where the oil level drops by a few mm overnight and recovers during the day. The most likely cause being the oil contracting as it cooled overnight and expanding again in the warmth of daytime. Perhaps the story about buying oil by volume on a cold day is true after all.

Circuit Diagram

cct.png
The circuit diagram shows how the ESP-07 module is connected to the VL53L1X. An FT242 USB adapter is temporarily connected to the ESP-07 for uploading the software and checking the operation. When the ESP-07 is put into deep sleep, the current drops to about 20 uA, a wake up signal resets the device via the diode.
It is possible to put the sensor into standby using the XSHUT pin but it proved easier to power the sensor on and off using a transistor. When the ESP-07 wakes up, the sensor is powered up and then switched off once a reading is taken. This also has the advantage of eliminating the VL53L1X standby current.
When it comes to uploading a new program, a 5k resistor needs holding between ground and GPIO0 as the unit is powered up to enter flash mode. After uploading the code, power the device on and off to run normally.

Battery Power

current.png

A single AA size lithium-thionyl chloride (Li-SOCI2) battery is used to power this project. Searching the internet should find suppliers of this type of battery for as little as $2 each. The big advantage of these batteries is the stable 3.6V over the life of the battery, ideal for powering the ESP8266 chip without requiring extra voltage regulation.
A tank of heating oil lasts many months and so the oil level only needs checking a few times a day at the most. Measurements on a completed monitor gave a deep sleep current of 22uA. The voltage waveform across a 0.5 Ohm resistor in the battery circuit indicated an average current of 75 mA for 6.9 seconds when awake.
Over a year, the circuit will use 193 mAh in sleep mode. If oil level measurements are taken every 7 hours then 180 mAh are used every year. On this basis, a 2600 mAh battery will last over 6 years.

WARNING

DO NOT HEAT BATTERY TO ABOVE 100'C TO AVOID EXPLOSION. CHECK DATASHEET AS THIS INCLUDES SOLDERING

Software

led.jpg

The Pololu Arduino VL53L1X library is used to initialise the range sensor and access the distance readings. Code for sending data to ThingSpeak comes from their Moisture Sensor example and some extra code drives the transistor that powers the sensor. The ESP8266 can only deep sleep for up to 70 minutes and wake itself up. The way round this problem is to allow the chip to wake up and immediately put it back to sleep, keeping a count in memory.
As the monitor connects to your WiFi network, you will need to include your WiFi SSID and password into the code. Also, if you use ThingSpeak, then add your API code.
The Arduino sketch for uploading is attached in the text file. It will need copying into your Arduino IDE. Before flashing the code, connect GPIO0 to ground via a 5k resistor before powering up.
The code for connecting the ESP-07 to the WiFI network is widely used in other projects. In this case, a much longer time was needed in the connecting loop for checking that a connection was made. About 500 ms is generally used but 5000 ms was required in this WiFi setup, worth adjusting if there are connection problems.
Details about receiving email reminders from ThingSpeak are described in the Water Softener Salt Monitor Instructable.

Assembly

vent.png
box.png
The components for the monitor are connected “birds nest” style around the ESP-07 module, sleeving anything that may short out. The module is easily damaged by too much heat and so these connections need soldering once and quickly. The monitor is assembled in two stages. First of all the sensor and ESP-07 are wired up with a temporary USB adapter to program the ESP-07 using the Arduino IDE. Using a short sleep time of 10 seconds will soon show if the chip is connecting to the WiFi network and sending readings to ThingSpeak. Once everything is working correctly, the chip is reprogrammed with the desired sleep times. The red LED should be levered off the module to minimise current consumption. Also, if an external antenna is connected, the ceramic antenna link also needs removing. Do not operate the chip without an antenna, the power will fry the chip rather than go into space.
The second stage involves removing the USB adapter and mounting the components in a box.
The VL53L1X module was mounted inside the tank vent cap using two nylon stand off spacers. Make sure the sensor has a clear view of the oil surface, no leaves, cobwebs or spiders in the way. Also, keep the connecting wire well away from the sensor to prevent spurious reflections.

Installation

front.jpg

The vent cap is replaced on the oil tank making sure it is level and no obstructions from the sensor to oil surface. The monitor is mounted next to the vent, small magnets were used to keep the box in place. This won’t work with plastic tanks!
Now sit back and check the oil level from the comfort of your home.