Oil tank depth gauge

Hi
I'm currently putting together a roomnode with an ultrasonic module in an effort to measure oil depth in my tank.

Member for

15 years 10 months

g7pkf

14 years 2 months ago

this is something i am very interested in.

 

especially now oil is in use :)

Member for

16 years 10 months

brett

14 years 2 months ago

You are almost there.

-From the RoomNode.pde Sketch you would tweak the number of bits from 8 to say 16.
struct {
    int oil:16;     // oil sensor: 0..32767
    byte moved :1;  // motion detector: 0..1
    byte humi  :7;  // humidity: 0..100
    int temp   :10; // temperature: -500..+500 (tenths)
    byte lobat :1;  // supply voltage dropped under 3.1V: 0..1
} payload;

From the roomNode.lua code (The receiver)

local oil, mo, hu, te, lo = jeenode.bitslicer(data,16,1,7,-10, 1)

If you want to move from a BYTE to say a WORD then just change the "byte light" and increase the number of bits in the receiver too - something like this and make this receive a new node type by renaming the classes and filename.

Like what I recommended here when I was talking about a new "boilerNode"

/content/temperature-measurement-hahnod…

Brett

Member for

14 years 6 months

magill

14 years 2 months ago

Thanks for that Brett
I got it sorted. It's working well and I can give details to anyone who's interested.
I attach a photo. The ultrasonic sensor is HC-SR04 from Ebay. I've also added a humidity/temp module (DHT 22 also from Ebay)
Attachments
OilTankSensor.jpg (31.61 KB)

Member for

15 years 10 months

g7pkf

14 years 2 months ago

any further info appreciated. (wiring code etc)

 

Parts ordered from ebay :) and roomnode from Derek :)

Dean

Member for

14 years 6 months

magill

14 years 1 month ago

Hi Dean
I attach the 3 files you need plus a rough drawing of the wiring required.
OilNodeApplet.lua and oilnode.lua go in the plugboard folder.
roomnode_oiltank.pde sketch to be uploaded to your roomnode.(you'll need DHT22 library)
You need to change the tank dimensions.Hope it is rectangular as the calculation for cylindrical tanks is quite complex.
I had to enlarge the hole in the top of my oil tank to accomodate the ultrasonic sensor. I have temporarilly put all the kit in a plastic lunch box with an airtight lid until I come up with a more permanent housing. The humi/temp sensor needs to be exposed to the elements but sheltered from direct rain.
I have written an android app for my phone to monitor these parameters, along with heating etc.
I'm happy to help with any queries.
Good luck
John
Update... there may be issues with battery life. Might have to consider larger battery pack or run 5V from a PSU in adjacent garage.

Attachments
OilNode.jpg (9.59 KB)
oilnode.lua (1.01 KB)
OilNodeApplet.lua (779 bytes)

Member for

15 years 10 months

g7pkf

14 years 1 month ago

The roomnode arrived yesterday ()thanks Derek() still waiting for sensors from china :)

Electronics is "my thing" coding isnt but i do have a programmer (and associated bit that goes with it) and AVR studio 4

 

and i have no idea what the DHT22 libary is (but i have downloaded it :)

 

all i have ever used the programmer for is to copy chips (when firmware updates come out) and i simply read the hex eprom and elf files then write them out to the new chip.

 

Looks like i am going to have to start reading how to get the code into the Chip :)

My tank is a 2500L bunded so its sort of rectangular but i am not too worried if its not 100% accurate-got to be better than my watchman with 10bars on it.

 

Dean

Member for

14 years 6 months

magill

14 years 1 month ago

Hi Dean
You are now into the Arduino world and need to download the free "Arduino development environment" at

http://arduino.cc/en/Main/Software. I'm using version 0023. You can program the roomnode directly from your PC using the

FTDI cable and choosing "UNO" as your board. Before you do this set up your node ID, RF etc. I only used the DHT22

because I had one, you may choose to ignore it.(I'm still messing with the code as the present setup is still eating

batteries)
I am very happy to program the chip for you if you like.
John
BTW what shape is your tank? Do you have it's inner dimensions.

Member for

15 years 10 months

g7pkf

14 years 1 month ago

Going to send you a chip. BUT i am also going to try and program my own and then compare.

 

can you send me your address? (will include a sae) my email is dean AT packetradio.co.uk

 

my tank is apx 2.2*1.1*1.1 Metres (2500L) and this is my second roomnode.

 

No rush still waiting for china stuff.

 

to reduce power could you not restrict TX to once an hour to help? (and increase TTL ) luckily i have power fairly near my tank :)

Member for

14 years 6 months

magill

14 years 1 month ago

Dean
I attach new (rough) drawing of the wiring. The transistors are any old NPN and PNP.
The purpose of these is to switch on the sensor only when doing measurements using the AIO pin to do this. Transistors are required because sensor is a 5V device.I also feed the temp/humi sensor from AIO on port 4 again only when reading values. Finally I have added a potential divider on port 2 which will return the exact battery voltage (using a scale factor in the sketch) I have reduced the measurement interval to 30 mins
John
Attachments
oilnode.lua (1.03 KB)
OilNodeApplet.lua (782 bytes)
oil-tank.pdf (16.82 KB)

Member for

15 years 10 months

g7pkf

14 years 1 month ago

Still debating if to go down the battery or run a cable route...

thinking the battery route for testing and cable route as a pernament soloution.

 

will let you know how i get on and will take photo's of construction.

 

Dean

Member for

14 years 6 months

magill

14 years 1 month ago

The sketch for the chip is different as it has to accomodate the transistor interface.

If you think that eventually you will run power to it, I will burn that version and you can test it with a battery pack anyway.

John

Member for

14 years 6 months

magill

14 years 1 month ago

The sensor seems to work down to approx 4.3 v but spec is 5v. I put a 10k resistor in the echo lead to protect the 328 chip. I'm not sure if it is necessary.

John

Member for

15 years 10 months

g7pkf

14 years 1 month ago

Somethink strange on XFX viewer.

 

http://www.packetradio.co.uk/gallery/index.php/HAH/photos/hahnode2

 

John i must ask do you have your oil tank in your living room?

 

Joking aside been testing and it looks really good, values are pretty accurate.

 

now all i need to do is weatherproof box it, run cable set it up on Gui and explain to wife 0=no heating :)

 

Dean

Member for

14 years 6 months

magill

14 years 1 month ago

Dean

I think I will move it to the living room so that I can observe it to see where all the oil is disappearing to.

I'm glad you have it sorted. You can tether it to COSM and watch the level drop!

John

Member for

15 years 10 months

g7pkf

14 years 1 month ago

Its working well :) just installed it on the oil tank this afternoon-late.

 

one question do you find oil level drops when the temp drops? only by 20L from a 16degree to 10degree temp change?

 

what/how do you find the accuracy over time/temp?

 

Once again thank you. running on 3 d cells at the moment as it was getting too cold to run a cable tonight (and SWMBO would have wabbled- she was iffy about me drilling holes in tank lid as it was! )

 

Dean

Member for

15 years 7 months

garrydwilms

14 years 1 month ago

Dean, is this possibly just thermal contraction?! Not sure what the thermal expansion coefficient is for fuel oil but on a 2500l tank you are only seeing <1% change on 6degrees which doesn't sound unreasonable to me. If this is the case you should be able to factor this out to give you a reading at a fixed temp?!

just a thought. 

 

Garry

Member for

14 years 6 months

magill

14 years 1 month ago

Garry is quite right. The thermal coefficient of expansion of diesel is 800 * 10 -6 which means that the fuel will expand by .08% per 10 degree rise.

Dean if you want I can modify the code to factor this in.

John

Member for

15 years 7 months

garrydwilms

14 years 1 month ago

0.8% change in volume for 10oC change, but either way I'm sure this is the cause and as John says easy to factor out. 

 

Factor = 0.0008 per oC

Factor for 10oC = 0.008 = 0.8%

 

i might be wrong it's been a while since i did stuff like this in anger ;) 

Member for

14 years 6 months

magill

14 years 1 month ago

Garry you're quite right it is .08% per degree and 0.8 for 10 degrees. Anyway that equates to 16 litre expansion of 2000 litres with 10 degree rise.

There are other factors eg expansion of container, speed of sound v temp (for echo) and ultimately the quality of the cheap and cheerful device.

Anyway I can unhappily watch my oil drain away on my phone, Joggler, and for a real treat look at the COSM graph.

John

PS You could always display the cost in £s intead of litres and maybe her indoors will turn the heating down!

Member for

15 years 10 months

g7pkf

14 years 1 month ago

PS You could always display the cost in £s intead of litres and maybe her indoors will turn the heating down!

 

I wish.

 

Yep forgot about expansion of liquids-set fire to physics lab when at school, used a bunsun instead of hot water-the petroleum went up well big hole in roof day off school!!

 

thanks all, quite happy to watch it expand and fall-might put a heater undertank so it uses less fuel---(JOKE)

 

 

Dean

Member for

14 years 6 months

magill

14 years 1 month ago

Just realized you can add this correction factor to the "oilnode.lua" the script now is:

module("oilnode", package.seeall)

require("xap.bsc")
jeenode = require("xap.jeenode")
Nodule = jeenode.Nodule
class = require("pl.class").class

class.OilNode(Nodule)

-- create BSC endpoints
function OilNode:build(...)
   Nodule.build(self, ...)

   -- Creates the endpoints: self[key] as in self.light, self.moved etc..
   -- If the user has configured that they want them that is.
   self:add {key="oil", direction=bsc.INPUT, type=bsc.STREAM}
   self:add {key="moved", direction=bsc.INPUT, type=bsc.BINARY}
   self:add {key="humi", direction=bsc.INPUT, type=bsc.STREAM}
   self:add {key="temp",  direction=bsc.INPUT, type=bsc.STREAM}
   self:add {key="lobat", direction=bsc.INPUT, type=bsc.BINARY}
end

function OilNode:process(data)

   local oi, mo, hu, te, lo = jeenode.bitslicer(data,16,1,7,-10, 1)
   te = te  / 10
    oi=math.floor(oi/(1+(.0008*te)))
   -- The keys here must match the key values from the self:add{key=x}
   Nodule.process(self,{oil=oi,moved=mo,humi=hu,temp=te,lobat=lo})
end

 

notice the new line

 oi=math.floor(oi/(1+(.0008*te)))+0

the "+0" bit is where you can put a plus or minus value to correct for inaccurate sensor height.

good luck

John

Member for

14 years 6 months

magill

13 years 11 months ago

Brett

If you get a minute, it will probably be obvious to you but on upgrade I get

lua: /etc/plugboard/oilnode.lua:8: attempt to call field 'OilNode' (a nil value)
stack traceback:
	/etc/plugboard/oilnode.lua:8: in main chunk
	[C]: in function 'require'
	/etc/plugboard/JMjeenodeApplet.lua:11: in main chunk
	[C]: in function 'require'
	/etc_ro_fs/plugboard/plugboard.lua:23: in function 'fun'
	/usr/share/lua/5.1/pl/tablex.lua:365: in function 'foreach'
	/etc_ro_fs/plugboard/plugboard.lua:75: in main chunk
	[C]: ?

I attach offending luas
thanks
John
Attachments
JMjeenodeApplet.lua (886 bytes)
oilnode.lua (1.06 KB)

Member for

16 years 10 months

brett

13 years 11 months ago

Depending on what build you are on as you never indicated (what after the upgrade meant)

If you are on 307

class = require("pl.class").class If you are on the BETA 307.2 then its like this

class = require("pl.class")

The penlight library had some internal changes when I uplifted it.

Brett

Member for

14 years 6 months

magill

13 years 11 months ago

I have done 2 firmware upgrade in the last 2 weeks. I have 2 liveboxes so I probably got mixed up.

I know I did an upgrade to 307.1 and did the "pl.class" mod. and it worked. I then did another upgrade. Has the firmware regressed to 307

Sorry for my ineptitude

John

Member for

16 years 10 months

brett

13 years 11 months ago

John,

You only get the point release BETA's by explicity updating to them.  307.1 has a bug with jeenodes and you need to update to the latest beta 307.2 - normally if you are on a beta is because you want to test something I just released but it may/may not work as expected, as so happened with 307.1 it was a bad build.  307.2 is good (so far).

There are differences in the PL library that may affect hand coded classes.

Brett

Member for

15 years 10 months

g7pkf

13 years 8 months ago

Been running this since october.

 

apart from having issues with power (my bad) it is working perfect.

 

the other day i got 500l delivered and my readings went from circa 190 to 700 Litres. so it is pretty accutrate. sometimes it goes full scale 2500 (it blips) but suspect this could be interferance from my watchman (that i run in the same tank)

 

so thank for the excellent desgn etc and if anyone is "thinking" about doing one i thoroughly recommend it.

 

dean

Member for

14 years 6 months

magill

13 years 8 months ago

My has been working ever since as well except for a period when it suddenly registered zero oil. It's at my holiday home and immediate reaction is that oil has been stolen. Turns out that rain had got into my makeshift container and soaked the electronics. I dried everything thoroughly and all came good!
John