Using Ultrasonic Sensors To Measure And Log Oil Tank Levels | Hackaday

[Mike] lives in a temperate rainforest in Alaska (we figured from his website’s name) and uses a 570 gallon oil tank to supply his furnace. Until now, he had no way of knowing how much oil was left in the tank and what his daily usage was. As he didn’t find any commercial product that could do what he wanted, he designed his own solution. In his write-up, [Mike] started by listing all the different sensors he had considered to measure the oil level and finally opted for an ultrasonic sensor. In his opinion, this kind of sensor is the best compromise between cost, ease of use, range and precision for his application. The precise chosen model was the ping))) bought from our favorite auction website for around $2.5.

[Mike] built the custom enclosure that you can see in the picture above using PVC parts. Enclosed are the ultrasonic sensor, a temperature sensor and an LED indicating the power status. On the other side of the CAT5 cable can be found an Arduino compatible board with an XBee shield and a 9V battery. Using another XBee shield and its USB adapter board, [Mike] can now wirelessly access the tank oil level log from his computer. Flow Meter Beer

Using Ultrasonic Sensors To Measure And Log Oil Tank Levels | Hackaday

I’m surprised he couldn’t find a COTS sensor. Centroid ( makes several styles. The fuel and water tank in my houseboat used these. They even have controllers that handle non-linear tanks.

I did some looking, but I didn’t come across that style. I will keep it in mind when I revisit this part.

I’ve been working on this type of project on and off for some time now. If I understood the construction correctly you used a #7 plastic with holes in it so you can place the transducers through. The fuel tank is a Hazardous location and classified as a Class II/ Division 2 / Group D, by the NFPA which is the governing body of the NEC (national electric code) and any electronics, unless they are “intrinsically safe” or in an “explosion proof enclosure” you are in violation of national and local codes. One of two things could happen. The tank could catch fire or if the local fire Marshall hears about he could find you. I am sorry for the bad news and thought you should know.

If anyone has a question I am now adding the follow-up comments via email. I forgot to add it in my original post.

Another major advantage of ultrasonic: it’s non-contact measurement. You don’t have to worry about the sensor actually being in contact with the stuff you’re measuring (as compared to a float sensor).

But you have to be careful. I use a Schneider ultrasonic sensor to monitor oil. Some have a rubber sensing end which absorbs the vapour over time like a sponge, and expands. There are stainless cased and hard plastic ended ones that are better. I use a 0-10v sensor connected via z wave module. Works brilliantly and very accurate

what is ‘our favorite auction site’ and is ‘2.5$’ supposed to be $2.50?

Our favorite auction site always used to be eBay, but it could have changed since 2 minutes ago. And I think it’s USD 2.50, sent from somewhere in China…

Thanks, thought maybe there was new site that all the cool kids were using.

Looks like it’s probably $25

You are right, the Maxbotix is around $25, the cheap one that I got from eBay was a Ping))) knockoff.

thanks for the heads up! corrected

Nice idea. My motorcycle aprilia don’t have gas measuring gauge and it have very curvy tank with two chambers . I think that this will be a great solution for it and for other motorcycles

Careful — motorcycles slosh. Also, it’s gasoline, which has issues with ignition (unlike fuel oil)

It will probably not work. If your tank is anything like the tank on my BMW you dont have line of sight from anywhere useful. Ultrasonic needs that. And that’s why we have a trip meter. In city driving I know I need to fill at around 240 miles.

its aprilia pegaso 650 and its like bmw pretty much .i have experience with sound equipment and acoustic instruments,simple tap on some chamber can tell you is it fool or not and how much , it can be done with in range of normal sound frequency but it will require some clever coding.

Oooh! We could make it really complicated! First, apply a 0hg vacuum to the tank. Then measure the amount of air it takes to fill the tank back to atmospheric pressure. You could measure the air volume with either a device that measure air volume, or through an orifice of known diameter, and the amount of time it takes. Don’t forget to account for altitude, temperature and humidity.

Actually, thinking of sound, how about simply determining the resonant frequency of the inside of the gas tank an using that to calculate the volume of air in the chamber?

There are sensors that use the principle but instead of the sound in the air they use soundwave waves travelling through a [partially submurged] metal rod. You can either measure the acoustic resonance of the rod, or listen for echoes as the ultrasonic sensors do.

“The precise chosen model was the Maxbotix EZ0 bought from our favorite auction website for around 2.5$.” he used the hc-sr04, not the Maxbotix EZ0 that cost $25.

That is one I didn’t find. I wonder what the precision is. I’m not sure how I would handle the 0.5 meter head space though.

Air gap is just a straight peace of pipe straight up and put sensor in the end. Pipe needs to be @least 3inch

Unfortunately, all the holes on the tank are 2″ so by time I thread something into the hole the inner diameter is even less. also has a full line of sensors. They give free 2 day shipping on orders over $50.00

U I use them at work on a do-more plc to web :)

Automation Direct is awesome. Their prices are excellent, and since they’re about 11 miles from me, I can pick up locally, or have things overnight.

I’ve been playing with PLC controllers the last several months as a result of a different project that indirectly involves them. I used one on a personal project, a pneumatically controlled can crusher. At work, I recently used one for automating a door cycling tester (presents a credential using a server, actuates the handle with a linear actuator, then another LA opens the door, the handle is released, and the door is closed. ADC channels are used to measure the position of the LAs).

Sure, I *could* have used an Arduino or Beagle Bone or Raspberry Pi, but a bottom of the line CLICK PLC is $69, comes with conditioned I/O, and was a great excuse to play with PLCs.

Oil delivery companies have been tracking the fuel use of their customers for decades. They model your furnace and your tank in their computer. They know the weather and they can calculate how much oil you are going to burn today. They can tell you within a gallon or so, how much oil you have in your tank. They will show up to refill your tank when it runs low. When they fill your tank they determine how much was left in your tank and they use this data to refine their model of your furnace. They negotiate a fixed per gallon price for the fuel, so it is in their best interest to deliver it efficiently. This has been common practice in New England since the ’70’s. You don’t need an oil level sensor, you need a weather station unit that can calculate and tabulate degree-days.

They probably do something like that here for those that choose automatic fillups. I like to choose when the credit card takes the hit. I do plan to add weather sensors as I can, but this allows me to compare running a space heater vs. no space heater or keeping the temp lower vs. higher. Ultimately, I would make it part of an alarm system as oil tanks get targeted by thieves.

While perhaps some of the oil delivery companies do this, it seems that others do not. I’m in New England, and the reason I came to this site is because this is the 2nd time that our oil company let our tank run dry. We’re on automatic fill and have been for years. It’s currently freezing; we have no heat tonight and can’t take a hot shower. Perhaps you are correct that they are trying to get the best prices for oil which may mean “running a bit low” sometimes. Obviously, they let us run a bit too low since we’re currently out of oil. So I am looking at buying or building my own measuring system, and I think they should probably get cracking on remote monitoring as well since obviously at least one New England company doesn’t do it right. (And yes, perhaps we could change oil delivery companies, but they also fix our boiler on a yearly service plan which is included and that has paid for itself in spades).

We’ve got a large water tank behind our house to collect rainwater. This summer I made sensor out of a hollow float (soft drink bottle with hot glue) on long rod, then at the other mounted on a long shaft potentiometer as a pivot. So less than $2 in parts for the sensor itself :D. Though this only works if your tank is more wide than it is tall and never fills up to the very top, at least not without some sort of fancy watertight potentiometer. The range from empty to full covers about a quarter of the available rotation of the potentiometer. I am gradually taking measurements by hand to properly calibrate the sensor. The goal is to know next summer how quickly we’re running through the water so we can adjust our garden’s watering regime accordingly.

When my flashlight is not working I light a match over the hole which gives off enough light to look inside.

You can earn an award because of that:

You can put out the match by dropping it, nothing will happen. Fuel oil will not explode unless heated and mixed correctly with air.

This looks like something I could use at work. We have a 20ft (approx) tall diesel tank for our equipment, and once a month someone has to take a ladder and a folding ruler out there, climb to the top, and measure the depth manually. Looking at the specs for this sensor, it looks like it may work for our tank as well.

You could build a handheld version and try it out. The NewPing library makes it pretty simple to use this sensor. The Maxbotix models should just work as well with a 6 meter range.

A handheld version would be handy to test it to see if it would work. Part of the appeal of this project is the promise of not having to climb up on top of that tank anymore though. :)

Mike, Excellent project. Thanks for documenting it so well. One thing that might help (from the photos) is a drip loop on your cat-5 cable. Just pull through about 40cm of slack and put a 20cm downward loop right where the cable enters the PVC housing (and another 20cm loop at the house end, too). The rainwater and condensation on the cable will drip off before it has a chance to ingress through your joint. Looking forward to part-2. :-)

I did put silicone around the cable and the LED. I think the only chance of moisture seeping in is where the piece of PVC enters the threaded adapter since I have not yet sealed that off. It seems pretty tight though and I haven’t noticed any moisture when I have checked it. For now it is too cold (low teens fahrenheit) to check for problems like that.

I have started writing up part 2. I was initially waiting on some data to get a better feel for the metrics I want to collect, but then I realized that I had some underpowered resistors and I am waiting on replacements. I did manage to collect some data and test out the system, but I have a few resistors that have darkened in color.

Use a large PVC end-cap with hole in end to OD of existing PVC. This will form a “hat-brim like porch roof” to direct moisture to drip outside the tank openings threads.

There is some kind of intrinsecally safe circuit somewhere? rememebr your measuring FUEL,. isn’t as volatile or flamable like gasoline but stills fuel.

That is one reason why I went with a non-contact method of measurement. I only included minimal components on the tank and they are baffled from the main interior which is vented.

Ultrasonic fuel level sensors have been around for sometime now. I always through that they are good for level sensing but not good for “emergency” situations like alarm states and emergency shut offs. I know they they have a tendency to fail when the fuel is splashed onto the them therefore you’ll still need a reed style float to trigger when there is too much fuel.

Anyone wish to comment on that?

They are among several kinds that have been around forever. The best is often the capacitive type that has capacitance sensing all along its length at short intervals, but that is also fairly expensive. Ultrasound is common, although in fuel applications they are typically a bit more…involved than what was done here. Float switches are a must for safety, although they can be supplanted by other technologies of adequate rating (although never ultrasonic, as far as I know). There are a lot of ways to measure level.

I think it depends on the design. A lot of backup sensors on cars use ultrasonic which should handle liquid. I did have problems for several days with some liquid getting on the screen on the front of the sensor, but it hasn’t been an issue for a while. I am fairly sure it is splash back from the return line and now the level has gotten low enough (around 500 gallons) to not be a problem any more. As far as I can tell, it was also not a problem until the level got down to 510 gallons, but that is only a 1 inch range that had problems. It is also possible that it was condensation or moisture somehow got into the PVC.

Damn I’ve been toying with this SAME IDEA for months now for my oil tank. My tank has a manual gauge though like this ( I was thinking of an ultrasonic sensor like he used or simply hooking an arm attached to a pot to the top of the gauge that’s already there and using it that way.

I am surprised I don’t see any of those types of gauges in town. I can’t imagine that there aren’t others around that want to keep an eye on general usage. I know some use auto-fill, but I would still want to see how fast it is going without having to go out and dip the tank all the time.

Lots of companies provide these types of sensors for fuel tanks levelcon and smartank are two out here on the west coast. Power consumption is really important in this setup as the fuel tanks we are talking about are often on farms in remote locations and need to run on batteries. I think this is the reason these companies use float or pressure sensors rather than ultrasonic.

Let’s all remember that Fuel “Oil” isn’t Oil – it’s Diesel. #2 Fuel oil is basically the same #2 Farm Diesel. We’re not talking like the difference between 10w-30 and gasoline. The viscosity of fuel oil is the same as that of diesel from the gas pump… and it also produces fumes in just the same way. Fumes that could ignite if given the chance to be sparked by electronics…

There is a waterproof sensor in aliexpress for around USD $7.00. The piezo sensor is enclose in a sort of liquid ingress proof casing, and attached to the board with a long cable.

try this one:

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Using Ultrasonic Sensors To Measure And Log Oil Tank Levels | Hackaday

Hydrostatic Level Transmitter By using our website and services, you expressly agree to the placement of our performance, functionality and advertising cookies. Learn more