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:
Step 1: PARTS NEEDED
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 (D0 on Photon)
4.) Grey - ECHO (D1 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.
33 Comments
5 years ago
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!
Reply 5 years ago
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.
Reply 5 years ago
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.... ;)
Reply 5 years ago
Take a look at this:
http://resources.heatingoilexpress.com/fuel-oil/ho...
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.
Reply 5 years ago
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:
https://www.amazon.com/Particle-PWRSHLD-Contains-C...
(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 battery...in 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: https://www.sparkfun.com/products/13626
(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 (https://www.cafago.com/en/p-l1613.html- 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: https://community.particle.io/t/sleep-mode-explai...
Also, take a look at the official documentation for the sleep function:
https://docs.particle.io/reference/firmware/photon... (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: https://www.sparkfun.com/products/13314 -- 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: https://www.sparkfun.com/products/13314 (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!
Reply 5 years ago
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 http://amzn.eu/13x7bN7 with 2.5W 5V rating.
And a cheap boost converter is on the way to power the ultrasonic sensor: http://amzn.eu/40OQINc 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.
Reply 5 years ago
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: https://www.instructables.com/id/Temperature-Compe... and also this: http://la3za.blogspot.com/2014/05/temperature-comp...
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 cold...it'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 10W...it'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.
Tip 6 months ago on Step 6
If the Photon is sold out, you can use the Argon as a drop in replacement. Just make sure the PVC cap you screw in is slightly larger to accommodate the taller size. Otherwise everything works as is.
https://store.particle.io/products/argon
6 months ago
thanks for detailed instructions. Have got to the action step as particle photon is on backorder. does this particle photon work with JSN-SR04T Waterproof Ultrasonic Module (less accurate and wide angle).. the problem I have that I have a 1.5" NPT opening on the top. so I may not be be able to seat in HC-SR04.
Reply 6 months ago
Take a look at this module too: TOF10120 (~$15)
This one comes in a better shape/with code examples/etc:
https://www.ebay.com/itm/254281853712
It uses a laser, and it's quite small. I think this will work with oil.
Reply 6 months ago
Glad you found it helpful!
You can get the Argon which is the newer "re-design" of the Photon. It's $29 and available now. It's slightly bigger, but comes with some really nice benefits, including charging/battery.
Yes, the JSN-SR04T will work with the Photon (and Argon) -- this may help: https://create.arduino.cc/projecthub/SurtrTech/mea...
Just FYI - the JSN is a minimum ping distance of 20mm (~7.87 inches) which may produce some issues when your tank is full and full-ish. You will have to create your own calibration for "full" and potentially even "low" distance.
For sizing - the HC-SR04 is 45mm (~1.77 inches) so if you have a 1.5" opening, the HC will not work. There is the Grove one (better than HC), but I believe that's even bigger at 50mm (~1.97 inches).
Question 3 years ago
Great Instructable! Do you think the sensor would withstand the fumes of a chlorine tank?
Reply 3 years ago
Definitely. No issues from the chlorine vapors.
Question 4 years ago on Step 8
But if we change the ultrasound sensor for a transducer pressure sensor?
I think is more accurate.
Reply 4 years ago
I believe you are right technically - it is much more accurate. That said, for "home use", the normal variations (ex: pump firing on and off, and the tilt angle of the tank, where on the tank you are taking measurements) create a much larger margin of error than the sensor's own margin of error.
For example, I've noticed that when the pump fires on and off, there is oil movement which can create a difference anywhere from a few gallons to ~10 gallons. Also, the tilt creates a ~5-6 gallon change (so on my tank, I have 2 of these sensors - one on each end, so I can measure the "high" point and the "low" point).
I was looking at 2 alternatives originally (the other being IR) -- but the reason I went with ultrasonic is because of the cheap cost and overall reliability. It's also very easy to work with both physically and software wise.
4 years ago
I have published the Instructable about my version of this idea. It is battery powered with solar panel charging, data logging on ThingSpeak, and temperature sensing. Have a look: https://www.instructables.com/id/Solar-powered-IoT-Ultrasonic-Oil-Tank-Monitor-by-S/
5 years ago
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.
Reply 5 years ago
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 ThingSpeak.com to track oil usage, temperature, and solar charging. Fun!
Reply 5 years ago
Steve - good to know. I got the same feeling (about the stability) from reading some of the reviews on this sensor. It seems to be "better", but a bit more flaky. Depending on your usage, I am assuming you can sleep for longer periods of time, and then poll a few times over a minute to "stabilize" the results. I am still using the HC-SRC04 here since the temperature is not a problem. It sounds like you might be better off with the MaxBotix sensors which seem to be incredibly accurate/resistant to weather. They seem to be rated for -40°C to +65°C (although recommended low is 0°C). The down side - they are a lot more expensive. By the way, that's a hardcore battery :) -- but to your point, needed for the colder temps. I keep seeing people building weather stations with LiPo batteries, and I am amazed that they make it through, but somehow they do. By the way, do you need to poll the sensor that often (every 60 seconds)? I would assume the oil should not change that much no? Thanks for the feedback on the sensor by the way!
5 years ago
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.