Measure Oil Level (or any liquid) and alert - hardware + firmware/code

Posting this in case someone finds it useful. I wanted a way to measure how much oil we have remaining at home, and I ended up creating some DIY hardware (including Photon, sensor, PVC, sealant, rubber gasket - less than $35 in total) + some code.

You can find everything here (detailed info + particle firmware/code + link to hardware):
https://blog.vpetkov.net/2017/11/12/diy-monitor-heating-oil-tank-gallons-with-pushbullet-sms-and-email-alerting/

The instructable I created is here (hardware itself):

6 Likes

Cool!

So what did the Oil company think about it as far as a useful product for their customers to be alerted of when oil gets low and the tank needs to be refilled?

1 Like

It’s funny that you ask about that - I was really paranoid at first about safety, so I actually took it to 2 local companies to get their thoughts/feedback on it (and eventually scheduled an appointment with the chief if fire safety just to double check), but now I am thinking of getting everyone on our street and using this so that we can get a single truck delivery and potentially get some $ off of the rate since it will be a win-win. From what I’ve read, their biggest cost is basically getting the driver+driving the truck, and having to do this on multiple days to the same street.

3 Likes

Seems like a useful and potentially money-saving feature the oil companies could offer.

There is a service that is going that way and uses Particle devices created by @ghovagim
They started of as HeatOracle and are now called TankClarity

2 Likes

Their monthly service seems a bit steep. I am assuming they are passing the Electron sim charge as is to the end-customer, and if you are using the Photon, it’s their enterprise/cloud cost that Particle charges.

There are a few competing services that use zigbee/zwave + an “ethernet station hub”, and those seem to charge $15-20/year.

A co-worker looked up the “Consumer Oil” market, and it turns out it’s very small. Most in the US, on the East coast (really Maine/NH and a bit in towns in MA, RI, CT, upstate NY, etc).

Someone could really take over this industry easily enough with any kind of intelligence, and it seems these guys are trying to do exactly that. One change I would suggest is placing the cost not with the end consumer but with the oil companies. They are potentially saving them so much money (especially w/ the custom routing that I saw on their site, if they can really do it well), that the $3-5/month for each user is pennies to the oil company compare to what they will save off of each person.

To give you an example of this - ours gives you 10 cents off per gallon if you pay within 10 days. That means on an average fill up (which is ~half a tank @125 gallons, sometimes as low as 80ish and sometimes as high as 130ish), this is already at $10-20/month per customer per fillup (average ~$60/year/customer). Given this service, everything could be auto linked to credit cards and they could get their $ instantly.

As you can tell, I’ve been thinking a lot about this lately :slight_smile:

There is tons of opportunity when it comes to doing things better, even just 10% better is all it takes.

Approaching these companies and making it easy to try and deploy this type of technology is the key. I wouldn’t expect them to instantly be excited about change, people and companies are creatures of habit. But these technologies are going to be adopted eventually.

Companies like https://www.enertrac.com/ are offering this service directly to oil distributors. Enertrac spun out of Senet, which is now focused on LoRaWAN network deployments.

1 Like

This is a nice use of the particle / electron. I designed something similar using a maxbotix ultrasonic sensor and pic micro a couple of years back. Some feedback:

  • a maxbotix sensor will report distance back very accurately via RS232, though high accuracy probably isn’t required for this type of use. It is smaller, and I was able to epoxy the whole sensor inside the cap and only drilled a small hole for the signal wires. Also, RS232 will go a longer distance if you need to locate the photon/electron further from the tank for some reason.
  • a lookup table would be a far more efficient way of mapping distance from the sensor to # of gallons in the tank and would make the implementation easier for other types of tanks (275 vertical / horizontal, 500, 750, 1000gal, etc). You should look into it (https://embeddedgurus.com/stack-overflow/2010/01/a-tutorial-on-lookup-tables-in-c/)
  • you are completely right about risk, there is zero risk of putting a sonar sensor in the cap of your oil tank. Oil boilers atomize the oil via a nozzle and extremely high pressure and mix it with a preset amount of oxygen and then ignite with an electronic spark. None of that has any chance of happening from a simple ultrasonic sensor in your tank cap.

Do ensure the seal to your tank is good. If air can leak out, during fills the filler will not get an accurate reading of when the tank is full and may overfill your tank.

1 Like

@thefloyd - Neat. Thanks for the info.

  • You are now the 3-4th person recommending maxbotix. When I looked at the site, the sensor I saw was a few hundred bucks (vs the $4 I am using)…it seemed theirs was for extremely high pressure applications and completely sealed for moisture/gases/etc. That said - I probably should look at them again since so many people are recommending them. Which sensor did you use?

  • Thanks for the lookup table idea. This was driving me nuts – the giant if-else block is beyond “not elegant”, and a horrific nightmare to keep update/change. As an past-life developer, it was making me cringe.

  • For the safety - thanks for confirming. At first I just didn’t know better. What bothered me was that someone on instructables told me “pressure could build up and blow up”. That made me take some “official” steps and schedule an appointment with the city’s chief of fire prevention so that they can inspect it/look at the use case/etc. My favorite comment was something along the lines of “you can flick lit matches in the tank, and it will still have a hard time exploding”…that and “there is no pressure anywhere in the tank” and something along hte lines of “even if the oil compression pump starts failing, and with the perfect cone shaped spray, it will stop igniting”

For the seal – I have it tightened as much as possible and with plumber’s tape which I am assuming should create a pretty good seal. The gasket membrane is rubber cemented so it should not leak air.

Thanks again for your feedback - i’ll look into the lookup tables. I was even considering calculating the formula (even though it will “approximate”), it should still be extremely accurate for this purpose, just so I don’t have to have a giant list.

oh no! you’re totally looking at the wrong maxbotix sensors, then! They ARE more costly than the sensor you’re using, but they’re NOWHERE near that expensive. What you want is the Maxbotix LV-MaxSonar-EZ series and they’re under 30 bucks… I forget which one has the most narrow beamwidth but whichever one that is, that’s what I used.

Anyway, it’s a great project and I might try and re-implement my solution using a photon (and your project as a framework) since the tie-in to the cloud is already there (my pic solution used BLE which required me to be at home to read the tank - why not do it through the cloud if I can?!).

If I add maxbotix support to your code I’ll be glad to share (but don’t count on me getting around to it unless I get bored :smiley: :smiley: )

2 Likes

By the way, I do think the fact that you spent as much time as you did validating the solution’s safety is awesome. The off-the-cuff statements are totally true, and they’re funny to give back to the usual uneducated internet trolls who think an oil tank is a time bomb waiting to go off in your basement! :slight_smile:

Given our current cold snap here on Long Island, if anyone still doubts the inherent safety of heating oil / diesel fuel come on by and try and get my F250 diesel to turn over without the block heater. It’s darn near impossible and that’s because it’s literally THAT HARD to get fuel oils to explode. :smiley:

2 Likes

They make some Maxibotix Ultrasonic sensors with i2c communication also now which would be easiest to interface with vs the other options.

On their website, they have tons of different options with the most expensive ones being in the $100+ range but normally they are in the $30 range. Adafruit, Sparkfun, and Amazon carry them.

Thanks - i'll check the out. The cheap ultrasonic is working well for this, but the cheap motion sensors I use absolutely suck (constantly false positives no matter how low I turn them), so that might be ideal for another project.

Yea, if I remember correctly these consume 2mA while ON which is pretty low.

I think they would work well for people detection.

@ventz, This is a neat project.
I copied/pasted the chart from the Tank Size WebPage that @thefloyd linked to Here, straight into MS Excel and created a trendline for each tank.

You could use a #Define Statement (or similar) at the beginning of the Code for the User to Select their Tank Size, and calculate the gallons directly in the Loop.

y = Gallons ,  x = Inches
Below are the Equations from Excel:
TANK :  EQUATION
275H :  y = 10.909x - 10.023
275V :  y = 6.8046x - 13.626
500  :  y = -0.005x3 + 0.3626x2 + 4.9946x - 4.7142
550  :  y = -0.0056x3 + 0.3993x2 + 5.2575x - 4.2845
1000 :  y = -0.0099x3 + 0.7115x2 + 9.8384x - 8.7038

Decent fits for a quick stab…

1 Like

Nice!

@Rftop - this is awesome. Thanks!
(I’ll definitely give you guys credit when I modify the firmware eventually with the equations!)

The other thing I need to figure out is the “base” distance away from the sensor that ends up being the “full”.
What makes this hard is that full (on a 275 tank for example) could be anywhere from 250 to 266 gallons. Usually they shoot for 250-255 but you never know. So I need to subtract the distance between the sensor height and the “top” of the oil line and call that the base start.

ps: this is why I love the Particle community – it’s because of things like this! :slight_smile:

I think the bottom of the height range is more important to the user than the top (“full”).
Once you’ve measured the height of Sensor Above the floor of the tank (45.9" in your code), you are calculating true Gallons Remaining, regardless of what’s considered “full”.

It’s completely valid to report 255 gallons remaining (of a 275 tank) as 93% full, instead of 100%.
You need the extra 4" at the top of the tank for the Sonar’s Min Distance anyway… take the win.

Thanks again for sharing your project !

Do you guys think Oil heating is used more in some parts of the country than others? Obviously, its not going to be needed as much in warmer parts of the country but I’m just curious how widely used it is today. I’m used to seeing Propane tanks around here.