pvvx / THB2

Custom firmware for Tuya devices on the PHY622x2 chipset
Other
135 stars 14 forks source link

Feature Request: Temperature range calibration #67

Open Cossid opened 1 week ago

Cossid commented 1 week ago

The CHT8310 supports the following temperature ranges

Temperature accuracy with calibration:
±0.2℃ (typ.) from 0℃ to 80℃
±0.4℃ (typ.) -20℃ to 100℃
±0.5℃ (typ.) -40℃ to 125℃

And the default appears to be ±0.2℃ (typ.) from 0℃ to 80℃

It would be nice to choose between these 3 ranges to make these sensors useful in freezers or cold outdoor settings.

This is just a sample from the CHT8310 specsheet, but CHT8305 and AHT20 also have similar calibration ranges with different accuracy zones.

pvvx commented 1 week ago

https://github.com/pvvx/pvvx.github.io/blob/master/THB2/CHT8310.Advanced.Datasheet_Ver1.0.20230407.pdf

CHT8305 image

CR2032 (and any CRxxxx) at -20C produce voltage below 2.5V. Not suitable for use in freezers.

At temperatures above +25C, the self-discharge of CR2032 increases...

Cossid commented 1 week ago

How about alkaline like the THB2 & BTH01? I'm aware cold weather isn't ideal for any battery, and alkaline supplies a lower starting voltage that lithium, but they do hold up better in colder environments typically.

pvvx commented 1 week ago

At the moment, there are statistics on the use of 2 AAA salt batteries in TS0201 in the freezer compartment of the refrigerator. Works in BLE - LE Long Range (PHY Coded) mode so that the signal can penetrate the iron body of the refrigerator. This is a little more power consumption than a typical BLE (PHY 1M). image The following effect has been observed: When batteries are heated briefly, their subsequent output increases. That is, AAA salt batteries freeze, and when defrosted briefly, partial recovery occurs. These are the cheapest batteries I found in stores...

pvvx commented 1 week ago

Behavior of the CHT8305 sensor in TH05_V1.3 when the battery voltage drops below 2.5V: image

THB1 (CHT8310) remains operational at 2.0V: image

PS: Do not buy thermometers with CHT8305 sensor: image image All thermometers are approximately at the same temperature, but thermometers with CHT8305 give incorrect temperature and humidity readings when the battery is discharged by 50%. In addition, CHT8305 has a higher consumption...

Cossid commented 1 week ago

Right, the THB2 with CHT8310 and 2xAAA batteries is my desired target for low temperature sensing.

I know 2xAAA is typically the standard for other outdoor/low temperature sensors, but it would be nice to have these as a potential, even if less efficient, option, as the price point for these sensors is substantially lower than more robust solutions.

pvvx commented 1 week ago

Thermometers with CR2032 are not suitable for use at large negative temperatures. Thermometers with larger CRxxxx batteries (CR2050, ...) withstand negative temperatures a little better, since CR2032 under normal conditions has a maximum output current equal to the pulse current consumption of the microcircuit.

And it is preferable to use a thermometer with a TLSR825x chipset.

Example of LYWSD03MMC operation outdoors. https://camo.githubusercontent.com/10259ed927fda7717d637ba9891599c670d4a4b5dcc468ff04cacf4c9e879ed3/68747470733a2f2f707676782e6769746875622e696f2f4154435f4d69546865726d6f6d657465722f696d672f576561746865722e676966 Already the third CR2032 battery.

https://pvvx.github.io/MJWSD05MMC/ on CR2450 it has been working for more than a year and a half without changing batteries (but at a temperature of +15..30C).

Available statistics for thermometers with PHY622x2: image (operating temperature +20..25C)

All Tuya thermometers have scattered readings and a small range of reception and transmission. Poor antenna layout, low quality sensors (the cheapest sensors are used), instabilities and bugs in the operation of PHY62x2 chips (depending on the batch).

The worst of all thermometers is TH05_V1.3. THB1 THB2 - have instability in BLE connection when working from a new battery (at a voltage of more than 2.5V). ipset or PCB layout issues. BTH01 - bad sensor (CHT8305).

Cossid commented 6 days ago

I've had terrible quality on CR2450 battery supply here, even indoors, most of the ones available at a reasonable price only last about 6-8 months. (CR2032 are usually more consistent quality, but I don't like coin batteries in general).

TLSR825x is hard to find in AAA with a good sensor and not requiring physical mods.

Which is why I would like to see this calibration option available for the THB2 with the 8310 and AAA batteries. AAA battery quality is easy to control, and even at 6 months in cold weather wouldn't be a huge deal for most, since they're so accessible.

pvvx commented 6 days ago

Which is why I would like to see this calibration option available for the THB2 with the 8310 and AAA batteries.

THB2 does not have a display. Accordingly, it is better to make adjustments in the receiving program. This is easy to do in Home Assistant and/or other programs.

Cossid commented 6 days ago

I don't follow. I don't think it's as simple as an offset. The readings are accurate in the 0-50C range, but below 0C, they become skewed, for example -18C actual temperature reads at about -13C

I think the sensor needs configuration changes in the 0x03 register (but I'm not certain). It sounds like the default mode just isn't meant to accurately report below 0C.

pvvx commented 6 days ago

I think the sensor needs configuration changes in the 0x03 register (but I'm not certain).

There is no setup of measurement ranges. There is only a switch to reduced accuracy.

Cossid commented 6 days ago

image

I read that as it needs reduced accuracy to go below 0C

pvvx commented 6 days ago
When EM bit is set as ‘0’ in default, the temperature resolution is 0.03125°C with the expression range of -128°C to 128°C. 
When EM bit is set as ‘1’, the temperature resolution is still 0.03125°C with the expression range of -256°C to 256°C.

This is the output format switching in the sensors register. Chinese translation.

The sensor crystal and PHY62x2 degrade at temperatures above +120C. Below -40C, the PHY62x2 will not work. The quartz crystal will not start.

The case will warp at +90C, the batteries will leak...

Cossid commented 6 days ago

Most freezers are around -18C which is a reasonable thing to monitor. I would not expect anyone to use these for -40C or +90C.

I don't fully understand the data format, but the spec sheet says the sensor should be able to handle it, but it currently is for sure skewed below 0C. To be fair, Tuya's firmware has the same limitation.

Here is a comparison against an Inkbird IBS-TH2 (unsure what sensor is inside). image

Above 0C they would be much closer together, so I'm assuming it is something with the configuration/driver, as the CHT8310 clearly can handle ranges below 0C.

pvvx commented 6 days ago

You haven't understood the most important thing: Tuya is a device from the trash heap (the cheapest configuration, often just defective parts from factories, parts that have been sitting in warehouses - instead of being recycled, assembled by small private companies, no guarantee, no checks, no certificates, ...)

Cossid commented 6 days ago

I understand these are poorly made devices, but the specs say they should be able to handle this quite easily.

pvvx commented 6 days ago

CHT sensors have very crooked characteristics. Nothing good can be done with them.

The PHY62x2 chip itself is already a multiple revision, but still has unstable internal generators and unfinished software in the chip's ROM. That's why they are worth nothing.

pvvx commented 6 days ago

Above 0C they would be much closer together, so I'm assuming it is something with the configuration/driver, as the CHT8310 clearly can handle ranges below 0C.

Please set the coefficients for CHT8310 sensor correctly in the PHY62x2BTHome.html program.


THB2 sensor ID: 8215.

image

Cossid commented 6 days ago

25606 is already the present value (as initiated by the device-specific firmware installed).

And it looks like adjusting that applies a linear adjustment, which is not what is incorrect here. At 0C-30C, this sensor is within tolerance of it's spec, but at -18C it is several degrees off.

pvvx commented 6 days ago

Internal crystal number: 8215 - read from the chip register. The inscription on the cover may be fake. The CHT8310 sensor is not designed to work below zero degrees:

image

Cossid commented 6 days ago

That is saying humidity won't be accurate below 0C, and that is fine. The line above says temperature to -40C. It doesn't look like you can disable humidity reading in any way though, but I wouldn't expect it to have an effect on the temperature portion.

pvvx commented 6 days ago

The Chinese factory that produces CHT sensors has translated the available PDF file from Chinese to English. This document cannot be trusted. It is not known what sensors are in the THB2. They may be defective CHT8215 that failed the tests and were marked specifically for a small underground company that assembles THB2 and sells it on the market... This is Tuya! You too can sign up for Tuya and sell all sorts of junk.

pvvx commented 6 days ago

I put THB2 (with the case removed) in the freezer next to TS0201(BLE). There is also a regular thermometer - its readings coincide with TS0201(BLE). Warm batteries in THB2 started to heat TS0201... Without the case, the THB2's reaction to cooling is faster... image

image

And so they will circle around each other...

Before this, THB2 was next to another thermometer at +23C, and the readings were: image

As a result, THB2 is fine at temperatures of +23C and -22C.

You probably have a defective sensor in THB2.

For three years, I have not adjusted any of the hundreds of thermometers. Their discrepancies do not exceed those described in the documentation for the sensors. More accurate and having small discrepancies (+-0.1C) - SHTxx are installed in Xiaomi (LYWSD03MMC, ...).


image

Measuring with two different thermometers (THB2 vs TS0201(BLE)) with the freezer turned off so that the temperature changes slowly: image