Introduce offset to temperature sensors

Having a bunch of similar sensors, I was wondering what would the best solution to introduce “some math” to a measurement before persistence and before rules.

Here is a chart (because it looks nice :)):

Those are Sonoff temp sensors. There are all in a +/- 0.2 degrees window.
Those sensors are all located next to each other so I doubt this 0.2 degrees is correct.

I also have other sensors that are way off, which is to be expected. I am aware that a simple offset is “not that simple” but considering those sensors are indoor, they don’t see a very wide range of temps.

What would be the best option to adjust the values of the sensor before further procesing (ie persistence, rules, etc…) in OH4 ?

Could transformations be used to do that ?

I is the difference consistent and linear across multiple temp ranges?
I also have several of those sonoff sensors and it seems on a few of mine there is more difference on lower temps conditions.
I have used transformations to alter sensor reading mainly for testing such as using temp changes to fake wind directions and such and it does work but if your offsets are varying based on ranges you might end up chasing ghosts. Also take into account round up and round down as that can sometimes toss you off as well.

On the whole range, it is likely non linear.
In theory, each sensor should/could be calibrated, although it assumes a good reference.

But for sensors that are indoor, the range is rather limited and I am fine with a simplication around 21-22 degrees.

My question is more about the technique in OH4 to apply “some math”. Once that is figured out, people can decide for a simple offset or more non linear calibration…

right couple of mine are in a garage area and I have seen a much larger difference when compared to a to real weather thermometer in same area. So any math will need to also adjust for a day and night winter summer variances to be really useful for me anyway. as well as one I have on a covered porch. Is why I asked what you see from range variances.
I also have tried other brands and seem to also have those differences between sensors . I even have Davis weather station outside temp enclosures and tested with sensors in them and it does not really change much. and compared that to my weather station high dollar sensors as reference.

For a simple offset, look for the ‘offset’ profile in the profile section of Items | openHAB

For more elaborate math that you want to define, see the transformations: Transformations | openHAB

1 Like

That looks perfect ! I will try that, thanks for the pointer !

OK, I really need to look into those :slight_smile:

@jswim788 beat me to mentioning the offset profile.

Personally, I wouldn’t be too concerned about a variance of +/- 0.2 degrees, unless you need scientific levels of precision. And if you needed that, you wouldn’t be using cheap Sonoffs. :wink: With a simple offset, you won’t have to go too far to the extremes for the offsets to fall apart, and then you might see results that are much worse than the raw figures.

You also just might not notice once you spread the sensors out in your house, since you’ll be reading different rooms and wouldn’t expect them to be identical.

If you want to get more complex, I’d just do it with proxy items and rules instead of transformations, because it doesn’t really change anything if you do the work before or after the data gets passed to an item. All that matters is the data you want to persist. With a rule, you can use conditions to apply different offsets relative to temperature ranges, so that each sensor is normalized to its most accurate reading. Then it’s easy to see what you’ve done and easy to add conditions as you dial in your sensors. It also preserves your raw data in case you want to work with that more in the future.

Very interesting. Indeed, I was thinking about Proxy Items but I want to stay away from such complication for this usage.

Do I care about +/- 0.2 degrees ? Not really. I just think that one of the reason for cheap sensors to be cheap is that they are not calibrated. So I don’t expect to do much “damage” by offsetting them properly. I guess time will tell. The offset option as @jswim788 mentioned is just what I was looking for. It is simple and I am not much engaged since I can set back the offset to 0 at any time.

Indeed, in the houre, there will be spread in values (btw I mentioned temperature but the topic applies to humidity etc…). This is expected and impossible to “verify” (at least not simply). However, I would like to be able to compare things properly.

To be honnest, I keep hearing from Sonoff for a while now and never had any of their products. After testing a few, I find them awesome for “non critical” (ie ZigBee vs Z-Wave) applications.
Today my desk filled up with many of those boxes and the good news is… it did not break my wallet !
So if it takes a little “effort” from me to “sync” those devices calibration, I will go for it.

For now, I will let those sensors run for a while and gather data. The temp. is 21 degrees right now and this is a pretty good reference for indoor sensors.

Many thanks for all the interesting answers so far. Each of them gives quite some nice options.

It’s more than that. Cheap sensors tend to be noisy and non-linear. A lot of them can’t be calibrated. And it’s really hard to calibrate a thermometer anyway because temperature can range quite a bit even across short distances.

They also tend to have a relatively narrow range where you can even trust the values they send in the first place.

For example, a DHT11 (which is in a lot of cheap thermometers) has a temp range between 0 °C to 50 °C with an accuracy of ± 2 °C. For humidity it’s even worse at a range of 20% to 90% and an accuracy of ± 5%. Even calibrated, that’s going to be quite a big range for acceptable error.

And I’ll add the old quote which I can’t for the life of me find the origin of:

If you have one thermometer you know the temperature. If you have two thermometers all you have is confusion.

This reminded me of a review of the SNZB-02P sensors @Will is using. They have SHT40 sensors with temperature accuracy at ±0.2°C/±0.4°F and humidity accuracy at ±2%RH. So, all of the sensors (except the last one in the screenshot) are performing exactly within their parameters.

@Will, this means that you probably won’t see any benefit from the offset, because the sensors won’t necessarily be off by the same amount every time. As you say though, doesn’t hurt to try.

This reminds me of the old days when our clocks weren’t all synchronized, and “let’s meet at 2pm” really meant “let’s meet some time close to 2pm”. Until about 15 years ago, we just accepted that time always came with a margin of error. :timer_clock:

1 Like

So far, I am impressed with those "cheap"s sensors.

I will plug 7 more today and keep collecting data.
Then I will set magic offsets :slight_smile: and see whether it gets worst or not.

FWIW, I don’t mean that as a knock on Sonoff. I’m quite happy with their new presence sensor.

But I’m also glad that you got the new versions, because they appear to have significantly improved their technology and quality without raising prices dramatically.

In contrast, their contact sensors have been frustrating for me, and I’ve replaced them with IKEA’s new PARASOLLs.

Holy cow, that’s a lot of sensors!

I saw your great post and I am testing it atm as well. Very impressed so far.

Holy cow, that’s a lot of sensors!

It is cheap ! :slight_smile: I want to support them !

1 Like

3 more in. The values keep right within the specs. No bad at all !

1 Like

Definitely not at all. How are the humidity figures? Also within the ±2% spec?

Here you go:

So, also right within the acceptable range. Nice.

I notice that some of the sensors appear to be reporting less frequently than the others. Is that due to settings?

Good question, I think they are set to report 0.1 degrees changes. I don’t know how to configure them yet. So far, I am persisting any change and everyhour (for the case when the temp does not change).

Indeed, some see to be jittering around their value and that triggers lots of persistence…
It does not bug me much, the only question is how long the batteries will last.
I am logging those too but there is nothing yet to see after those few hours of test.

Are you using the Zigbee binding or Zigbee2mqtt?

I use z2m, and I just noticed that there’s an offset parameter in the device settings.

This might not show up in the Zigbee binding if Sonoff didn’t follow the Zigbee standard.

It doesn’t look like you can adjust the reporting frequency, though. I’m surprised by that.

I want to test Zigbee2mqtt but I did not install it yet.

I use z2m, and I just noticed that there’s an offset parameter in the device settings.

That makes sense for those devices but I actually like the idea of being able to do that in OH so we are independant from the bindings…

It doesn’t look like you can adjust the reporting frequency, though. I’m surprised by that.

I would not mind that not bing possible if the batteries hold.