## Oil Tank Monitor Project

ldavies293
Posts: 6
Joined: Sat Mar 09, 2013 8:05 am

### Oil Tank Monitor Project

Hi All - I have a second project I wired up last week and thought some of you might be interested in it. I've pulled a couple of tutorials/forum threads together to cobble together an Oil Tank Monitor that gives you a pretty good idea of your tank consumption:
Screen Shot 2014-08-05 at 22.57.41.png (59.74 KiB) Viewed 6129 times
This was based on two main projects:
http://alaskanshade.blogspot.co.uk/2013 ... ow-to.html (for the hardware)
and
https://github.com/sculley/raspberry_pi ... -interface (design inspiration)

Some different shots of the hardware here:
https://www.icloud.com/photostream/#A2Grq0zw9cI9Z

General procedure:
• Drill two holes in the top of a brand new £800 oil tank (eeek! )
• Python script running as a daemon on the rpi - I know c type programs would give me a higher level of accuracy being lower level, but this pi is only doing one thing for me and a small variance in quantities I could accept.
• Once this script captures Indoor Temperature, Tank Temperature and Distance to Oil - It submits that to my webservice (just a simple form based webservice on a HTTP GET request)
• A PHP script on my server logs the request onto a MySQL database along with the calculated Tank Quantity - This was a lot of fun(!) because although the Tank was brand new - I had no clue what the exact internal dimensions of the tank were to calculate volume. What I did know was the tank WAS empty and I had 1000 Litres pumped into it from the oil company. So a dipstick measurement and some simple maths gave me a magical "Litres per mm" value. All I needed to do now was calculate the distance of the maximum quantity for the tank was in mm (1070 Litres) and then subtract that value from the measured distance value of the sensor to get the number of mm's remaining in the tank. Multiply that by your magical "Litres per mm" figure and hey presto you have an estimated (but pretty darned close) litres remaining reading.
• Finally theres a frontend page based on Scully's work that plots the internal & tank Temps as well as remaining quantity of oil onto a google chart (based on a php JSON file) and then some simple maths to work out litre consumption and costs per day.
Sorry for the wordy thread - I wanted to get it down whilst I could still remember it. Stuff I'd like to resolve (and maybe you can help?) or improve are:
• Thermal volume expansion of oils - this ones a new one on me but makes sense - I couldn't work out why the capacity of the tank was fluctuating so much (2-3 litres in the 1000 litres in there every day) - I then spoke to an chemicals engineer for an oil company and realised volume changes and there is a rule of thumb on the volumetric change - so I may be able to minimise the "jitter" in the code, but would appreciate any help people can give me on that.
• Dual Y axis google chart - so the scale isnt so skewed out showing 2 extremes (0-1000). Never got my head around Google Charts dual axis using a Json response (from the feeder)
• Other reporting, e.g. cost since last fillup, cost over last 7 days etc
• Integrate with my HotPi project - I wrote a little project last year that controlled the central heating via a Rpi and Relay board etc, I'd like to know when the boiler is turned on how much oil is consumed etc - Oil aint gettin cheap and I'd like to remote control the heating. This will take a while - I need to dust off the old vero board and get it working.
Thats about it really - very happy with the outcome and quite a few people are impressed with the results so thought I'd share.

Let me know what you think

baylor7
Posts: 12
Joined: Wed Aug 06, 2014 2:28 am

### Re: Oil Tank Monitor Project

really cool project man. I work in the oil field as well.

rgrbic
Posts: 128
Joined: Thu Jun 12, 2014 1:07 pm
Contact: Website

### Re: Oil Tank Monitor Project

Cool project. Maybe pressure sensor can help you in volume determination but this requires closed tank.
At 127.0.0.1
Twitter: @rgrbic
IoT-projects.com

ldavies293
Posts: 6
Joined: Sat Mar 09, 2013 8:05 am

### Re: Oil Tank Monitor Project

Thanks both - I did wonder about pressure sensors however ultrasonic sensors seemed cheaper/easier for me at the time. I've enjoyed doing so far - so will probably keep tweaking it

BioniC187
Posts: 26
Joined: Sun Jun 02, 2013 6:30 am

### Re: Oil Tank Monitor Project

Nice project mate.

I couldn't help but notice that from the picture, it seems the ultrasonic sensor is not, as far as possible, level to the surface of the fluid.
If it is not, you may get inaccuracy in readings as the level drops.

On to the next question. Volumetric change of oil.

I can't remember the formula off hand, but there is a formula where you can plug in the temperature of the fluid, some thermal property of the fluid(i think), and you will be able to work out a volume.

Then you get a standard volume for oil for a temperature of 20 deg, and find the difference, and that difference is your change in volume

rgrbic
Posts: 128
Joined: Thu Jun 12, 2014 1:07 pm
Contact: Website

### Re: Oil Tank Monitor Project

BioniC187 wrote: On to the next question. Volumetric change of oil.

I can't remember the formula off hand, but there is a formula where you can plug in the temperature of the fluid, some thermal property of the fluid(i think), and you will be able to work out a volume.

Then you get a standard volume for oil for a temperature of 20 deg, and find the difference, and that difference is your change in volume
You are probably pointing at thermal expansion relations. These are based on known volumetrical coefficients of thermal expansion. See this calculator for example.
At 127.0.0.1
Twitter: @rgrbic
IoT-projects.com

Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

### Re: Oil Tank Monitor Project

Liters per MM is only accurate if you have a 'linear' tank.
A cubic shape or a cylinder standing on its base.
Otherwise have to do a bit more complex calculations.
I did that for an uncle of mine when I was in university, I could not do it now.
I remember it being something of a integral over a circle shape.
(A change in the middle is a lot more volume then a change at the start or end)

raspberrypiguy1
Posts: 379
Joined: Sun Sep 02, 2012 7:01 pm

### Re: Oil Tank Monitor Project

This is really interesting considering the fact that I spent a week at BP HQ doing work experience as a control systems engineer. My task was something along these lines: compare and decide on a technology for the measurement of liquid in a 3-phase gaseous liquid oil separation unit.

Essentially it was all about the engineering involved with accurately measuring oil, water and gas in the separation units. This is especially hard as these giant tanks are under immense pressure and heat. They're normally located on the rig as well. Simply put: oil, gas and water come out of the ground when we dig for oil. A 3-phase separation unit separates all of these but it is very very important to keep the levels of oil, water and gas at constant heights (as the whole process works with gravity). In order to monitor this BP use different technologies to measure the heights of the liquids/gases. These are those technologies:

· Differential Pressure

· Guided wave radar

· Capacitance

· Nucleonic level measurement – Gamma rays Profiler

If you're interested give them a Google to learn about the different options - some pretty complicated engineering is involved with them. I ended up choosing the nucleonic option. It costs a quarter of a million pounds but was the only really accurate method - essentially BP fires gamma rays through the vessel and as the different substances have different densities you can see exactly how much of each there are.

Rambling over. I probably didn't help anyone here but I enjoyed the chance to share a little bit of rather specialist knowledge

Thanks

Matt
The Raspberry Pi Guy
Matt, The Raspberry Pi Guy YouTube channel, author of Learn Robotics with Raspberry Pi, available now: http://mybook.to/raspirobots, Computer Science & Electronics Undergraduate at The University of Edinburgh

ldavies293
Posts: 6
Joined: Sat Mar 09, 2013 8:05 am

### Re: Oil Tank Monitor Project

Thanks for all the comments - they are getting a bit "geeky" even for me

Firstly - I was fresh out of Nucleonics - I suppose theres a reason why the usual household ultrasonic sensors only measure oil tank capacity in 20% increments because it cant be done neatly.

The shape of the tank is quite uniform for the purposes I require and so I to be honest the only way I could get even a close idea of the total volume is the Litres per mm, however if there's another way of measuring the oil in an inexpensive way happy to discuss, The systems temporarily out of action at the moment as I transfer it to a slice of pi board to be a slightly more permanent fixture, hopefully get it back online this weekend sometime.

Would anyone be interested in some source code at all?

bradjg23
Posts: 1
Joined: Wed Oct 01, 2014 11:54 pm

### Re: Oil Tank Monitor Project

Hey I am working on a similar project and would definitely appreciate some source code.
Thanks for this post!

Return to “Automation, sensing and robotics”