zigbee-plant-sensor icon indicating copy to clipboard operation
zigbee-plant-sensor copied to clipboard

Temperature readings wrong around with negative temperatures

Open oleo65 opened this issue 2 years ago • 9 comments

I am experiencing a strange behaviour with the reported temperature values in Home Assistant via ZHA integration.

Currently we have negative temperatures outside but the reported temperatures are not. The chart probably best describes the behaviour.

Screenshot 2022-12-14 140506

At first I suspected a signed/unsigned integer error but the source code seems fine to me. Is there any setting with the SHTC3 sensor which might cause this?

I can rule out a defective device since all three sensor which I placed outside are showing the same behaviour.

oleo65 avatar Dec 15 '22 09:12 oleo65

As I am currently setting up some zigbee plant sensors (thanks for this great project by the way!) I tried to reproduce the situation shown above. While I can't confirm the weird behavior of the temperature rising, mine also have strage behaviour around the 0°C mark. When placed outside they move down to just below the 0° mark quite quickly and stay there (moving between -0.3 and -0.7), even though it is actually around -8°C outside.

image

bbadaboom avatar Dec 18 '22 10:12 bbadaboom

@oleo65 your are using ZHA I assume? @bbadaboom what are you using?

I've place one sensor in the freezer and for me it works fine as you can see in the image (it is not the best freezer). Did you build the image yourself or did you use the prebuild file in the release section?

Screenshot from 2022-12-18 13-58-31

At first I did not expect people to place them outside so I did not optimize the code for large temperature fluctuations. For example the ADC is not re-calibrate when the temperature changes more that 10 degrees. Keep in mind that the clock might also become more inaccurate at lower temperatures, so the battery life might drop when placed outside.

stanvn avatar Dec 18 '22 13:12 stanvn

Yes I use the Home Assistant ZHA integration and compiled the firmware myself.

Your chart shows exactly the same strange behavior around 0 degrees and then dropping further, also below 0. That is exactly the issue I was describing above. The temperature readings are off by a few degrees then, at least way out of the tolerance limits of the SHTC3 sensor.

With a different firmware on the identical hardware I do not experience this issue.

oleo65 avatar Dec 18 '22 13:12 oleo65

You’re right, I thought it was because I did open the fridge once, but apparently it is the same issue. I’ll investigate it feather, hopefully it is something that can be fixed easily.

stanvn avatar Dec 18 '22 16:12 stanvn

After some digging I found a bug in the SHTCx driver from zephyr. I've added a quick fix in the main repo. Could someone verify if this solves the issue?

stanvn avatar Dec 18 '22 20:12 stanvn

I might be able to try tomorrow. Thanks for researching this.

oleo65 avatar Dec 18 '22 20:12 oleo65

I just put a freshly flashed parasite in the freezer and it went down to -20°C. So I would say this is resolved.

oleo65 avatar Dec 19 '22 14:12 oleo65

Haven't managed to compile my own hex file yet so I can't test at the moment. (Hoping to get there some time around christmas, but so far have no experience with zephyr and I kinda want to know what I am doing, not just blindly installing everything and compiling... ;))

bbadaboom avatar Dec 19 '22 17:12 bbadaboom

Sorry for the delay due to the holidays, but here is a hex file you can use to test. Let me know if this solves your issue. https://drive.google.com/file/d/1I_ztPCfgGjZiIEiXSXvrhQuPan2Sl1yL/view?usp=sharing

stanvn avatar Jan 10 '23 15:01 stanvn