Tag Archives: node

Calibrating temperature/humidity with mqtt

Example uses a shelly sensor, which has a offset mode in its new firmware. So below is not needed any more.
But the example can be used for any calibration/adjustments.

I’ve put two examples in the NodeRed function

First the solution

var temperature=msg.payload.tC;
var humidity=msg.payload.tF;
// calc new offset example
// simple offset + 2.3 off real measurement
msg.payload.tC=temperature + 2.3;
// more complex example
// take two measurements (with a big difference)
msg.payload.tF=1.11 * (humidity - 1);
return msg;

First adjustment is plus or minus a value.
Second is more precise when the temperature needs more adjusting

Dots on the red line are measured values
Blue is how it should be

So measured was 2.8 but should be 2
And measured 14.5 but needs to be 15

slope = (14.5-2.8)/(15-2) = 0.9

To get the multiplication factor = 1/0.9 = 1.1111

=(2.8-heightadjust)*1,1111 should give us 2

2/1.1111 = 2.8 – heightadjust

1.8 = 2.8 – heightadjust = 1

So the formula is realhumid = 1,1111 * ( measuredhumid – adjust )