Converting Span to Percentage / Another Span

Hi All,

I dont know how to phrase this, and I am not feeling well today, so my brain is working at half speed.

Anyway, I have a SR04 Ultrasonic Distance Sensor feeding into Nodered (via Tasmota) for a Water Tank.

When the tank is full, the distance to sensor is 19cm, when the tank is empty, the distance to sensor is 150cm.

I need a way to convert the span of 19cm->150cm into 100% to 0% or similar, so that it is more humanly readable.

Is there an easy way to do this. I would probably figure it out if I was firing on all 4 cylinders today.


Found the 'Range' Node. That looks like it is what I was looking for,


Indeed it is... should be fine for simple cases... If your tank is some other shape (tapered for example) then Bart's tank volume node may be better

The tanks are cylindrical, so it is easy enough to do that span using that Range Node.


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.