Feed Manipulation Problem

Good Evening,

I’ve got a script running which picks up the oil level in my tank (from a 433MHz transmitter) and publishes it to MQTT. I can pickup the feed in emoncms but I’m having problems manipulating it. The ‘depth’ reading I get from the transmitter is actually the level of free space in the tank (currently 16cm) which isn’t a particularly useful reading. What I’d actually like is the % full measurement which I’ve tried to do (unsuccessfully) by manipulating the data:

The depth reading I’ve attempted to publish to MQTT and also log are being stored as 0 rather than 87. Have I made some obvious noob mistake here? 120 is the height of my rectangular tanks (in cm).

Many thanks

Craig

How about

x -1 (to invert the sign)
+ 120 (to get the level)
x 0.833333333 (can’t divide by 120 so multiply by 83.333, and multiply by 100 for percentage)
log2feed
publish2mqtt

eg input value of 16

-16
104
86.666 (%)

Fantastic! That’s far more elegant and worked a treat thanks!

1 Like

Or if you really want the minimum number of steps
+ -120
× -0.8333333
…etc

2 Likes