[![english](https://img.shields.io/badge/language-english-C1C1C1?style=for-the-badge)](README.md) [![russian](https://img.shields.io/badge/also%20available%20in-russian-blue?style=for-the-badge)](README-ru.md) # BTHome THB1, THB2, THB3, BTH01, TH05 (HW: v1.3..1.6), TH05F, iSearching Custom firmware for Tuya devices based on the PHY622x2 chipset. (!) It is not recommended to buy Tuya thermometers with CHT8305 sensors and/or BL55028 LCD driver chips. They have increased consumption and are not compatible with battery operation. This is a dummy thermometer from Tuya. | [THB1](https://pvvx.github.io/THB1) | [THB2](https://pvvx.github.io/THB2) | [THB3](https://pvvx.github.io/THB3) | [BTH01](https://pvvx.github.io/BTH01/) | |:---:|:---:|:---:|:---:| | | | | | | [TH05_V1.3](https://pvvx.github.io/TH05-v1.3) | [TH05_V1.4](https://pvvx.github.io/TH-05) | [TH05F](https://pvvx.github.io/TH05F) | [KEY2 (iSearching)](https://pvvx.github.io/iSearching) | |:---:|:---:|:---:|:---:| | | | | | | | | | Support "[FindMy](https://github.com/pvvx/THB2/issues/94)" | This firmware works with [Home Assistant](https://www.home-assistant.io/) and other software running in the [BTHome](https://bthome.io/) format. All firmware supports any of these sensors: [CHT8215](pvvx.github.io/THB2/CHT8315%20Advanced%20Datasheet%20Ver1.6%2020230927.pdf) ([CHT8310](https://pvvx.github.io/THB2/CHT8310%20Advanced%20Datasheet%20Ver1.1%2020230927.pdf)), [CHT8305](https://github.com/pvvx/pvvx.github.io/blob/master/THB2/CHT8305C%20Advanced%20Datasheet%20Ver2.5%202021-10-26.pdf), [CHT832x](pvvx.github.io/THB2/CHT832X%20Advanced%20Datasheet%20Ver1.pdf), AHT20..30. **Software for setting up and making BLE OTA: [PHY62x2BTHome.html](https://pvvx.github.io/THB2/web/PHY62x2BTHome.html).** * The OTA protocol used is not part of the PHY SDK, but is designed specifically for custom firmware. This protocol, bootloader, and Flash area allocation scheme are incompatible with other PHY62x2 devices built on the [original SDK](https://github.com/pvvx/PHY62x2). The SDK used has been completely redesigned and has full sources for building in GCC. > Uploading OTA files to [PHY62x2BTHome.html](https://pvvx.github.io/THB2/web/PHY62x2BTHome.html) is automatic. You don't need to download files from this repository for OTA. > To run [PHY62x2BTHome.html](https://pvvx.github.io/THB2/web/PHY62x2BTHome.html) offline, just copy the [html](bthome_phy6222/web/PHY62x2BTHome.html) file to a local folder. ## Getting started with the device To work with the device, you need to write the `FW Boot` firmware to the device via a USB-COM adapter. Boot firmware is a program with reduced functionality and provides secure OTA updates. Next, using the BLE connection in PHY62x2BTHome.html through the OTA tab, the main operating program of the `FW APP` is recorded. * `FW APP` can also be recorded using a USB-COM adapter. ## Boot and App firmware The [Boot](#fw-boot-and-ota) firmware has minimal functions. `FW Boot` is only used for downloading via OTA the full-featured version of `FW APP` (`.bin` files). * The device type can be distinguished externally by the smiley face symbol on the screen. | Device | Boot file | OTA file | Printed circuit board labelling | |:---:|:---:|:---:|:---:| | [THB1](https://pvvx.github.io/THB1) | BOOT_THB1_v20.hex | THB1_v20.bin | no | | [THB2](https://pvvx.github.io/THB2) | BOOT_THB2_v20.hex | THB2_v20.bin | no | | [THB3](https://pvvx.github.io/THB3) | BOOT_THB2_v20.hex | THB2_v20.bin | no | | [BTH01](https://pvvx.github.io/BTH01) | BOOT_BTH01_v20.hex | BTH01_v20.bin | no | | [TH05_V1.4](https://pvvx.github.io/TH-05) | BOOT_TH05_v20.hex | TH05_v20.bin | TH05_V1.4, TH05_V1.5, TH05_V1.6 (chip: BL55028) | | [TH05_V1.3](https://pvvx.github.io/TH05-v1.3) | BOOT_TH05D_v20.hex | TH05D_v20.bin | RSH-TH05-V1.3 (chip: BL55072) | | [TH05F](https://pvvx.github.io/TH05F) | BOOT_TH05F_v20.hex | TH05F_v20.bin | TH05Y_V1.1, TH05Y_V1.2, TH05Y_V3.1 (chip: QD01 2332 NT) | | [KEY2](https://pvvx.github.io/iSearching) | BOOT_KEY2_v20.hex | KEY2_v20.bin | SoC ST17H66B | The main firmware files, BOOT_XXX_vXX.hex (for programming via USB-COM adapter) and XXX_vXX.bin (for OTA), are located in the [bin](bin) directory. Files for updating boot via OTA are located in the [update_boot](update_boot) directory. ** > The current version of `FW Boot` is **v2.0**. ## Internal GPIO pinout: | Firmware | Sensor SDA/SCL/Power | LCD SDA/SCL/Power | Key | LED | TRG(TX) | IN(RX) | |:---:|:---:|:---:|:---:|:---:|:---:|:---:| | THB1 | P18/P20/- | P34/P33/- | P01 | - | P09 | P10 | | THB2 | P18/P20/- | - | P07 | P26 | P20 | P18 | | THB3 | P18/P20/- | P34/P33/- | P01 | - | P09 | P10 | | BTH01 | P33/P34/P00 | - | P14 | P15 | P20 | P18 | | TH05 | P33/P34/P00 | P33/P34/P02 | P14 | - | P20 | P18 | | TH05D | P31/P32/- | P11/P14/- | P02 | - | P09 | P10 | | TH05F | P33/P34/P00 | P26/P31/P02 | P14 | - | P20 | P18 | The LCD chip is initialized the same way in all variants, but the connection ports are different. The LCD has different segment layouts depending on the model. The sensors are detected automatically, but have different ports depending on the model. ## Main features **With default settings**: * BLE advertisement interval in [BTHome v2](https://bthome.io) format is 5 seconds. * Humidity and temperature sensor is polled every second BLE advertisement interval - period of 10 seconds. * Battery voltage measurement is done every minute. * Recording of history every 30 minutes. * The button is used for quick connection to old BT adapters. Pressing the button switches the BLE advertising interval to a shorter period (1562.5ms). The action will continue for 60 seconds, then the interval will be restored to the one set in the settings. * The measured average consumption from a 3.3V source when scanning THB2 and BTH01 thermometers in passive mode is up to 8 µA. For TH05_V1.4 the average consumption is about 23 µA ([this is the current of the installed components](https://github.com/pvvx/THB2/issues/8#issuecomment-1908982171)). Other versions with screen: 12 to 14 µA with LCD on and 7 to 12 µA with LCD off. * Connection interval with Connect Latency (900ms). * Handling of input counter contact for transmitted [Open/Close events](https://github.com/pvvx/THB2/issues/10#issuecomment-1935169274) * Processing of output contact switchable by set temperature and/or humidity with hysteresis. * Support low-cost [BLE to Zigbee advertising repeater](https://github.com/pvvx/TLB2Z) ## Version History | Version | Description | |---|--- | | 1.0 | | | 1.1 | | | 1.2 | | | 1.3 | | 1.4 | | | 1.5 | | | 1.6 |