Monitor Heating Oil Tank Gallons With Email, SMS, and Pushbullet Alerting





Introduction: Monitor Heating Oil Tank Gallons With Email, SMS, and Pushbullet Alerting

SAFETY INFORMATION: In case anyone wants to know if "this is safe to build/install" -- I have taken this to 2 different Oil companies for feedback/safety considerations, and I have run this by the fire department's Fire Prevention Deputy Chief. Per all 3 - the device is considered completely safe with norisk of fire or explosion. That said, I cannot control your individual environment/what you do with it, so please assume your own risk when installing it. Per the oil companies - electric sparks/open flames will not ignite the oil, so there is no possibility of catching fire/explosion/etc. Nothing compresses/creates a vacuum/creates air pressure to cause an explosion. My favorite quote was "even if you flick lit matches in your oil tank, it will not catch on fire."

This is a very quick and easy DIY build for a system that lets you monitor your home oil tank level (in *exact* gallons - down to the 10th of a gallon) remotely, and alert on different levels via Email/SMS/Pushbullet, etc.

The entire build is meant to be quick, clean, and less than $40!

The key parts are a Particle Photon for the "intelligence", a HC-SR04 for the "sound pulse" which will be used to measure the distance to the oil and using some data charts calculate the exact number of gallons avaiable, and a nice PVC shell for an easy build which can be directly screwed in into the tank.

I've made sure to provide a lot of images (especially of a few gotcha's) in order to make this as easy as possible.

For more information, background, and code (and feedback/comments), please go to my blog:


1.) You need about $4-5 worth of 2" PVC:

a.) 2" Male Adapter (left side)
b.) 2" Female Adapter (right side)
c.) 2" Cleanout Plug (bottom/middle)

2.) You need a rubber gasket "sheet" that's ~3x3 or bigger. This is ~$1.25-1.50

3.) You need a HC-SR04 sensor. You can get 5-6 of them for $8-10 (don't pay more than $2/each).
This is essentially a "trigger"/"echo" supersonic module..

4.) You need a Particle Photon (wifi) - $20
(alternatively, if you don't have WIFI access, you can get the Particle Electron - more expensive, and uses SIM card that's $3/month)

5.) Cables -- Jumper cables (female-to-female), and MicroUSB cable+usbpower (not pictured - could be replaced w/ battery)

Step 2: Mark the Circle and Cut It Out

Mark the circle size and cut it out. This will be used as a seal/barrier between the chambers. It will also protect your electronic components, prevent oil fumes, and add other safety solutions.

Don't worry about exact size for now. Make sure it's bigger rather than smaller -- you will trim it down eventually to fit perfectly.

Step 3: Rubber Cement Male and Female PVC Together

Rubber Cement Male and Female PVC together as pictured.

The idea is two fold - create a secure PVC structure that has enough space to keep all of the components + keep any potential oil fumes out.

Step 4: Mark HC-SR04 Sensor, Cut It Out, Fit It In

1.) You want to mark the sensor in the center of your disk.

2.) Cut +'s (PLUS/Xs), but do NOT cut out the holes yet. (it helps with the bending/accuracy to wait for this until the disk is the right size).

I've broken this into many images to show the problems you might run into:

a.) The FIRST problem you will probably run into is the folds (see image tags for examples). You don't want this. If you run into this, take it out, size the rubber disk down a little, and try again. Once it fits, take it out and then cut out the circles.

b.) The SECOND problem you might run into is the rubber gasket not being pushed all the way. You really want it to fit into the "lip" that's left between the male and female adapters. This is the PERFECT place to "tuck in" the rubber gasket. You can see it in one of the images.

c.) After you get a good fit (see images), take it out, and THEN cut it -- but make sure the circles are slightly smaller than the markings. You want a tighter fit.

d.) At last, rubber cement the edges.

Step 5: Insert the HC-SR04 and Rubber Cement It From the Outside

The next step is to carefully bend the pins on the sensor so that they stick up. This will make it easier to connect to it when you have it inserted.

Insert the HC-SR04 sensor, and then push it all the way through.

Once that's done, use the rubber cement to "glue" the surrounding edges around the holes.

Step 6: Connect Header Cables, and Add the Photon

Connect the female-to-female header cables to the HC-SR04. You need 4 of them.

1.) WHITE - to the VCC (5v)

2.) BLACK - to the GND (Ground)

3.) Purple - TRIGGER (D01 on Photon)

4.) Grey - ECHO (D02 on Photon)

You will want to connect a microUSB cable to power the photon. Ideally, you can route it through the square cap (the Cleanout Plug).

Step 7: You Are DONE - Here's the Code

Final Product - you now just need to find one of the 2" `bungholes` on your tank, and unscrew the metal cap and screw in this.

The code for the Particle Photon, and some background can be found here:

If you have any comments/questions/feedback, please post a comment on my blog. I'll try to answer/help with anything that I can.

Step 8: Particle Photon - Screenshots of Code/Firmware + Library

Hopefully this should clarify the:

What if you have never used a Particle Photon? Detailed Help on setup/code/flashing!

section from the blog.

It walks you through creating the "app", pasting the code, attaching the library, and then saving/compiling/and flashing.

Step 9: Particle Photon - Web Hooks - Notifications (Pushbullet, SMS, Email)

Hopefully this should clarify the:

What are these Web Hooks/Notifications – step by step instructions

section from the blog.

It walks you through creating the "webhook" - and some information about it.



  • Epilog Challenge 9

    Epilog Challenge 9
  • Paper Contest 2018

    Paper Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge

We have a be nice policy.
Please be positive and constructive.




POWER QUESTIONS: Have you tried to use the HC-SR04 and Photon with a battery? My tank is outside, so no power nearby to plug in to. I will probably use a solar cell to recharge it. I think the HC-SR04 needs 5V, so a boost converter or two LiPo or Li-ion cells in series and a voltage regulator would be needed, right? If yours is always plugged in, you probably did not bother with sleep mode and interrupts to wake. But if you know how to implement sleeping to save power, please add that to this instructable. Thanks!

Steve - pinging you directly because I have made a significant change to the code which I think you will need. Please take a look at the new one. This is the correct code for vertical oil tanks -- which appear to be the standard. The previous is for the horizontal tanks. Also, I have changed the alerts/levels so that they are much more practical.

Thanks for keeping me updated, Ventz! Actually, there is very little of your original code left in my version, as I have been busy with my own mods. Gallons are not used here (Ireland) so I was not using the table anyway. My tank is 1000L horizontal with some internal structure that was causing sound reflections. I think I have solved that problem. But the internal structure (which displaces a significant volume of oil) will require a difficult calibration process for each such tank to get true litres.

But I had lots of other problems related to solar and batteries that I am still working on. I will post the results when it is all working reliably. I am just waiting for some sun now, to see if solar charging is working.... ;)

Take a look at this:

It might be helpful in calculating the exact measurements with a direct formula.

By the way, thanks to the extreme weather we have had recently, I've had the pleasure of testing the sensor down to some very low temperatures (~ -17-18C), and so far it seems to be accurate.

Steve - yea I have. Actually the first time I started using the HC-SR04, after getting it to work quickly, the first real project was with a lipo battery.

The HC-SR04 does need a 5V. I've tried with 3V and while it "sometimes works", it's not reliable.

Take a look at the Particle Power shield -- this is by far the easiest and "everything you need" included one:

(NOTE: it comes with a large lipo included which is nice, and it has some other nice benefits like multiple charge options, over charge, current protection, volt/amp meters, etc. There is one down side around disconnecting the battery physically for a while and trigger powering it back on when it's later connected after 2 hours -- but you won't run into that with this project since you don't need to constantly disconnect/re-connect the fact, it will probably just stay connected)

All you would do is attach the the external powered solar panels.

I would recommend the Particle powershield because then you don't need a boost converter, you don't need any regulators, and you pretty much don't need anything else. "It just works". You need to be careful about which pins you use on the photon (I think the first couple end up being reserved for the power measure functionality), but past that, it's basically "plug and use".

Alternatively, you can take a look at the sparkfun battery shield:
(NOTE: it does not come with a lipo, thus half the price, and it's much simpler, but roughly the same. It has a few less features, but it's smaller. Sparkfun also makes one for charging from solar panels, but that requires more parts and I don't recommend it for this)

I have not played with the Sparkfun one but a lot of friends have said good things about it.

For the solar panels, I did a lot of research, and at the end realized that I could spend ~$65-80/panel for "nicer brandname" ones, or I could get these ( actually on sale for $14 right now) super thin "generic/no-brand name" which are IP65 rated water proof and paper thin. You can even easily chain two of them. Because they are so light, you can mount them with zip ties which is fantastic! I have 2 of these panels, and I am very happy with them.

Because of the functionality of the oil tank, and because you don't actually need to monitor it often/in real time, you can put the photon and especially the wifi chip to sleep, and then you can get away with VERY little battery. If you wake it up 1-2 times a day, measure, connect online, send results (or just connect when bellow a threshold), you can go for 60-80 days easily on the lipo charge that comes with the photon powershield. Thus the solar panel will be more than enough. Take a look at this for more information:

Also, take a look at the official documentation for the sleep function: (search for "Backup RAM (SRAM)", and look at the chart right under that for the options/what they do)

Something you will have to deal with is water sealing the components - but that's easy. You can sealant spray the whole thing or use rubber cement on the outside. I would use teflon tape ("plumber's tape") for all of the threaded/screw in components to create better seals and keep the rain/moisture out.

At last - about the temperatures, you are more than ok. The particle photon is rated for: -40 C to +85 C, and the HC-SR04 is rated for: -15°C to 70°C

You can easily add a tiny temperature sensor. I would recommend this one: -- it's all self contained, and you don't have to add anything other than the headers you need. Alternatively, if you want something smaller/cheaper, you can get this: (but you need a resistor, and it needs to be soldered to the legs + it's harder to attach the photon in a removable fashion). I would stick with the #13314 personally.

Good luck!

Thanks, Ventz, for the helpful advice and links. I had already gotten for this project the SparkFun Photon Battery Shield, and already had a Li-ion cell to use with it. Those notebook solar cells look great. Are they really 10W?!? I had already gotten a smaller one, at 2 for £12 with 2.5W 5V rating.

And a cheap boost converter is on the way to power the ultrasonic sensor: at £9 for 5. I did not find anything in the Particle power shield documents about it having a regulated 5V output.

Regarding temperature, I was not worried about the electronics not working, but just needing recalibration as the temperature changes, since the speed of sound changes with air temperature, and so do crystals' frequency. I have a bunch of DS18B20 digital temp sensors that are very similar to the Max31820 you suggested. If any of you have already implemented a temp calibration curve for HC-SR04, let us know.

To be honest - I have not had to deal with crazy cold temperatures yet when using the sensor. I would assume there is some standard of calibration based on degrees above/bellow a certain point. I did find this which seems to talk about exactly that: and also this:

Per the 2nd link, it seems like the base library (formula) is good for +/-30 C. I would assume that should be good enough for's probably heat that's the problem. The 2nd link also has the author's code on the bottom that deals with the temperature.

Funny - the panels you chose is what I had decided on from amazon before I found the no-name ones I ended up with (and yes - they really are's crazy for that price point). This is what happens when you don't get the middle man markup. The down side is that you don't get fancy charging ports, but it does have a micro USB attached and sealed, although you will probably have to re-seal whatever you connect into that port. Given the low power requirements behind this project, I think almost any panel will be fine. The bigger concern is lithium ion in low temperatures.

I like the DS18B20s too - especially the nicely sealed ones, which seem ideal for water/snow/non-ideal conditions.

If anyone here needs to do this outside in *extreme* temperatures, it seems like the "US-100" sensor is a better choice (~$4). It has a built-in temperature sensor, and it auto-corrects for extreme temperatures.

Hi Ventz, On your suggestion, I switched my HC-SR04 with a US-100 sensor, and am using it in digital (serial) mode. This simplifies the Photon code (by putting the distance calculating into the sensor) and seems to correct for temperature. But it is a bit flakier, and sends junk and needs to be reset once in a while. I appreciate getting mm precision where the HC-SR04 had only cm precision. I think the US-100 is accurate to about 3mm. I had to install a PVC pipe in my tank, which the sensor pings down to sense the oil level, because I was getting hell from various sound reflections off the internal structure off the tank. The pipe is open at the bottom with a notch so that oil will be at the same level inside it as out. Solar charging was also a lot of learning and mods I had to do. It is now working great, with 60-second sleeps between measurements using a 6Ah lead acid gel cell battery, which can easily stand the Irish cold, unlike a LiPo battery. I am also using to track oil usage, temperature, and solar charging. Fun!

UPDATE: 12/26/2017 (Dec. 26th 2017) - I have made significant changes and updates to the photon code and "table" implementation to work with the 275 gallon VERTICAL tanks (which are "normal/standard" oil tanks used in the United States). I have also changed the interval and "zones" for the alerts so that they are more practical. If you have created this project, please just pull the new code and re-flash your photon. You will notice very granule gallon detection/ranges along with some other improvements.