Heating oil tank; dip values in cm, convert to litres

I’m trying to use Emoncms to log my heating oil consumption by measuring the level of oil in the tank in the garden.

I have set up…

  • Emoncms hub on a raspberry pi.
  • DVB-T usb stick and rtl_433 to capture the oil level from the tanks wireless dipstick.
  • rtl_433 sends the dip valve in cm to Emoncms’ MQTT server and can be logged and graphed in Emoncms.

What I would like to do is convert the dip in cm in to volume of oil in tank, but the tank does not have straight sides.

For example, for dip vales…
0 - 40cm volume = 11ltr/cm
40 - 80cm volume = 9ltr/cm
80 - 120cm volume = 12ltr/cm

Is it possible to do some sort of conditional calculations on the input to feed process?

I’ve looked through the list of operators and there is a section of ‘if > skip next’ style operators, but just can’t get my head round how / if these could be used in the above situation.

Any pointers would be appreciated.

Welcome, @eoilmon to the OEM forum.

Possibly what is causing the confusion is that a most useful process that goes with the “if…” conditionals is listed a long way further up the list – it’s GOTO.

The “if…” is useful on its own provided that what you want to do can be accomplished in one step. In your case that’s likely not to be the case, so you will need to use GOTO to jump to a section with multiple commands, then jump out again.

I suggest you first write out the commands on paper, and step through doing the calculation manually to check what you have is coming right.

The simplest calculation would be something like this:

  1. if > 80, volume = level * 12 - 160
  2. if > 40, volume = level * 9 + 80
  3. else, volume = level * 11

This is quite tricky to do with process steps, so look at using GOTO as Robert suggests. You’ll have to do a lot of upside thinking, with condtions that don’t skip gotos.

Another approach would be make some intermediate calculations, log them to temporary feeds, and add them together at the end. A bit wasteful perhaps, but simpler to debug. The tempory feeds could be MySQL Memory, if that’s available to you.

  1. Max value allowed = 40, x 11, log to temp1
    RESET to Original
  2. Subtract 40, Allow positive, Max value allowed = 40, x 9, log to temp2
    RESET to Original
  3. Subtract 80, Allow positive, x 12, + feed temp1, + feed temp2
1 Like