Page 1 of 1

Oil level monitoring system

Posted: Friday 30 October 2015 17:59
by Kouseri
Hi,

I've done a oil level monitoring system for my brother with Arduino and Domoticz. The Domoticz is running in a Raspberry Pi 2 at my brothers house
and takes care of normal house monitoring stuff including temperarature measurements and oil tank fill rate monitoring. The Arduino based oil level monitoring system takes care of fill rate of the oil tank.
The oil tank monitoring system consists following components (Raspberry Pi 2 is excluded from the list)
  1. Arduino Uno
  2. WiFi shield
  3. DS18B20 digital temperature sensor
  4. Ultrasonic sensor MB1010 from MaxBotix
DS18B20 digital temperature sensor is connected to the Arduino with OneWire bus. The Ultrasonic sensor is connected to the Arduino with single GPIO and is used in pulse width mode.
Ultrasonic sensor measures Time of Flight (ToF) data which can be converted to distance between the ultrasonic sensor and level of oil. Temperature data is used in calculations
about actual distance from the sensor to the level of oil because speed of sound changes in a function of temperature. Thermal expansion of the oil is not taken into account.

All the data to the Domoticz is transmitted via WiFi in LAN using the MQTT protocol. In practice all the "intelligence" is in the Domoticz and therefore for example decision about is oil tank empty
enough for notification to end user is done by the Domoticz.

The DS18B20 is connected to the Arduino system via two wire cable and RCA connector. The ultrasonic sensor is placed in a small enclosure which is fixed on top of manhole's hatch.
The connection between the ultrasonic sensor and the Arduino is taken care with three wire cable and 3.5mm AV connector.

In the following pictures one can see key components of the monitoring system.
Oil level logger
Oil level logger
Oil_level_logger.jpg (375.39 KiB) Viewed 6360 times
Sensors installed on the oil tank
Sensors installed on the oil tank
Installed_sensors.jpg (390.91 KiB) Viewed 6360 times
Arduino installed
Arduino installed
Arduino_installed.jpg (107.18 KiB) Viewed 6360 times
More information including codes and schematics about the Arduino based oil level monitoring system can be found from the GitHub.

https://github.com/MikaPetteriLundgren/ ... vel-Logger

Re: Oil level monitoring system

Posted: Saturday 12 December 2015 0:38
by dwmw2
Impressive work.

Please could you describe the Domoticz side of the setup in a little more detail? I've posted a script at http://www.domoticz.com/wiki/Lua_-_Oil_Tank_Monitor which turns ultrasonic depth readings into percentages and a volume in litres, although I think I'm using the wrong virtual sensor type for the latter. It would be good to compare with what you've done.

Re: Oil level monitoring system

Posted: Sunday 13 December 2015 21:43
by Kouseri
Thanks.

Actually I've created a percentage and temperature sensors (virtual sensors) for this purpose that are updated by the Arduino via MQTT protocol. The Arduino calculates the level of oil tank in percentage so
Domoticz doesn't need to take care of it. Temperature sensor is only for nice to know information and is not used by the Domoticz for any calculations.
Oil tank percentage sensor
Oil tank percentage sensor
Utility_sensors.png (27.39 KiB) Viewed 6078 times
There is a lua script running in the Domoticz which monitors the level of the oil tank. The script sends an email and a notification if the level of the oil tank is lower than a pre-defined limit.
The script can be found from the Github

So the Domoticz side of implementation is pretty simple.

Re: Oil level monitoring system

Posted: Tuesday 15 December 2015 0:56
by dwmw2
Thanks. I've filed a feature request for a sensor type which would allow us to report a value in litres instead of just a percentage: http://www.domoticz.com/forum/tracker.php?p=2&t=657

Out of interest, are you compensating for expansion of the oil with temperature? 1000l of oil at -10°C will expand to 1035l by 25°C. Which is small, but not negligible. Once I've got the graphs running properly, I'll be able to work out if the compensation adds noise, or smooths it out.

Re: Oil level monitoring system

Posted: Friday 18 December 2015 18:34
by Kouseri
dwmw2 wrote:Thanks. I've filed a feature request for a sensor type which would allow us to report a value in litres instead of just a percentage: http://www.domoticz.com/forum/tracker.php?p=2&t=657
Great, hopefully this will be implemented...

Currently I'm doing temperature compensation only in ToF (Time of Flight) calculations. The compensation is based on Maxbotix's application guide.

I've been planning to take care thermal expansion of the oil into account but implementation is still missing... :D
I've done an excel based "calculator" which can be used to estimate an affect of temperature to amount of oil. The "calculator" can be found via following link: http://1drv.ms/1K7JR20

Re: Oil level monitoring system

Posted: Sunday 10 April 2016 9:17
by pkriek
i

I am working on the same, and do have an distance meter installed on the oil tank using the mysensors gateway.
So in domoticz I have a sensor reporting distance.

I want to convert the distance into percentage and volume, I looked at the script to posted here, http://www.domoticz.com/wiki/Lua_-_Oil_Tank_Monitor

this looks what I am looking for, but I dont understand how to use it. I have the distance in Domoticz already, what do I do next??
I tried the output sensor commands, but tris does not work, most likely because I do not now how to use and where to run them.

can you set me in the right direction?

thanks

Patrick

Re: Oil level monitoring system

Posted: Saturday 16 April 2016 23:07
by Kouseri
pkriek wrote:i
I want to convert the distance into percentage and volume, I looked at the script to posted here, http://www.domoticz.com/wiki/Lua_-_Oil_Tank_Monitor

this looks what I am looking for, but I dont understand how to use it. I have the distance in Domoticz already, what do I do next??
I tried the output sensor commands, but tris does not work, most likely because I do not now how to use and where to run them.

can you set me in the right direction?
What about sending percentage to the Domoticz instead of the distance? Currently I'm doing distance to percentage calculations in the Arduino which is taking care of the distance measurements. I do have a lua script in Domoticz which informs a user if level of oil tank is lower than a predefined limit. That script will convert percentage to volume (liters) and adds the volume information to the notifications. The script can be found from the github: script_device_oiltank.lua

Re: Oil level monitoring system

Posted: Tuesday 09 August 2016 16:51
by stuiow
How is this project going?
I ordered a cheap dvb-t receiver to receive data from my Apollo smart and i see support has been added to Domoticz for tank capacities and moisture measurements (as of a recent beta anyway).

Re: Oil level monitoring system

Posted: Tuesday 09 August 2016 18:30
by Kouseri
stuiow wrote:How is this project going?
I ordered a cheap dvb-t receiver to receive data from my Apollo smart and i see support has been added to Domoticz for tank capacities and moisture measurements (as of a recent beta anyway).
This project has been in "production" already about 6 months and has been working pretty well. I have added a median filter and thermal expansion of oil features to the Arduino code and those features seem to be working as they should.