Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuya BLE sensor: BTH01 #1

Open
user784213 opened this issue Dec 27, 2023 · 64 comments
Open

Tuya BLE sensor: BTH01 #1

user784213 opened this issue Dec 27, 2023 · 64 comments

Comments

@user784213
Copy link

Hello
I have a very similar sensor: BTH01
Marking on SoC: PHY6222QCW04IYOJSH (PHY6222QC-W04C)
Marking on sensor: 8305 (CHT8305C)
The case looks cheap, same as TS0202, disassembles very easily
Current price on Aliexpress is less than $2
BTH1

@pvvx
Copy link
Owner

pvvx commented Dec 27, 2023

Разработка PHY6222 только началась.
Пока не будет ОТА, не будет и новых прошивок и не будут выложены исходные коды.

Development of PHY6222 has just begun.
Until there is an OTA, there will be no new firmware and the source codes will not be posted.

@pvvx
Copy link
Owner

pvvx commented Dec 28, 2023

@pvvx
Copy link
Owner

pvvx commented Jan 14, 2024

Соединения на печатной плате BTH01

N ножки чипа Куда соединен Маркировка Название вывода чипа
1 Через R2 на С11 + Сенсор Vdd CHT8305_VDD GPIO_P00
32 Сенсор SCL + R4 на Сенсор Vdd CHT8305_SCL GPIO_P34
31 Сенсор SDA + R5 на Сенсор Vdd CHT8305_SDA GPIO_P33
7   TM TM
8   TX1 GPIO_P09
9   RX1 GPIO_P10
11 Кнопка S1 (работает на GND) + C2  + R8 на Vbat   GPIO_P14
20   RX2 GPIO_P18
21   TX2 GPIO_P20
22 C10 на GND REST_N RST_N
15 Через R7 на светодиод D1   GPIO_P15
27   P25 GPIO_P25

@pvvx
Copy link
Owner

pvvx commented Jan 14, 2024

Тестовая прошивка для BTH01 готова, протестирована.
image

@theanch92
Copy link

Hi, first of all thank you for the hard work done! I just flashed your latest firmware BTH01_v05.hex on a BTH01, Bluetooth communication works but the temperature and humidity values were 0, the battery value is fine.
Looking on pcb, my BTH01 appears to have the AHT30 sensor and not the CHT8305C.

20240115_130200
20240115_125843

I have hope that you can also implement this sensor? Thanks so much again!

@pvvx
Copy link
Owner

pvvx commented Jan 20, 2024

I don't have AHT30 yet. But I added processing code. There is no opportunity to check yet...
OTA version coming soon - It will be possible to change the firmware regardless of the sensors.

@theanch92
Copy link

I don't have AHT30 yet. But I added processing code. There is no opportunity to check yet... OTA version coming soon - It will be possible to change the firmware regardless of the sensors.

Flashed FW 0.7 and the AHT30 works perfectly!
Also installed on TH05 and here too everything is perfect!

Great job

@NeoMatrixJR
Copy link

I don't have AHT30 yet. But I added processing code. There is no opportunity to check yet... OTA version coming soon - It will be possible to change the firmware regardless of the sensors.

Flashed FW 0.7 and the AHT30 works perfectly! Also installed on TH05 and here too everything is perfect!

Great job

Did you flash OTA with the example site or did you solder in? Is this fully functioning firmware to add to home assistant via proxy and still has functional screen or is this just testing getting custom firmware on the device? I tried the example web page but it wouldn't list my test device.

@sstidl
Copy link

sstidl commented Jan 24, 2024

@pvvx Hi Victor! I have v0.6 flashed via serial. can i update to 0.7 OTA? or do I have to do this over serial a last time?

@pvvx
Copy link
Owner

pvvx commented Jan 24, 2024

v0.x is the firmware for tests.
While the firmware number is not 1.x or higher, these are test firmwares and many things do not work in them.
Normal OTA will be from version 1.0.
If the firmware works, then there is no need to change it until v1.0 is released.

@g6094199
Copy link

he guys.

sorry but i dont gt how to get the chip to flash mode?
must TM pulled to high (3.3V)? or have i to pull RST (which PIN is this?) to GND?
or what else is wrong?

@sstidl
Copy link

sstidl commented Jan 25, 2024

he guys.

sorry but i dont gt how to get the chip to flash mode? must TM pulled to high (3.3V)? or have i to pull RST (which PIN is this?) to GND? or what else is wrong?

In my case it worked with TM left open and RST shortly pulled to GND
At the same time try to connect with the python script

@pvvx
Copy link
Owner

pvvx commented Jan 26, 2024

USB-UART PCB
RX TX1
TX RX1
RTS REST_N
GND -Vbat
+3.3V +Vbat

@g6094199
Copy link

g6094199 commented Feb 2, 2024

USB-UART PCB
RX TX1
TX RX1
RTS REST_N
GND -Vbat
+3.3V +Vbat

with RTS to REST_N i get

PHY62x2 - Reset Ok
Error read Revision!

but with " RST shortly pulled to GND" it works.

@pvvx
Copy link
Owner

pvvx commented Feb 4, 2024

but with " RST shortly pulled to GND" it works.

Linux ? - Everything is crooked there.

@g6094199
Copy link

g6094199 commented Feb 4, 2024

but with " RST shortly pulled to GND" it works.

Linux ? - Everything is crooked there.

yes, never used windoze in 20 years. so linux is my natural OS.

@TheNitek
Copy link

PHY62x2 - Reset Ok
Error read Revision!

I have the same error with windows, trying to reset manually (I use a arduino uno with board with the atmel removed as a serial adapter and reset line is not availble, I think.)

@g6094199
Copy link

its tricky...even with another instance inbetween. i started the flash and grounded the pin afterwards shortly. you maybe have to play with the timing

@TheNitek
Copy link

Since i get the "Reset ok" message, I guess my timing is ok, but it's still unable to read the revision

@g6094199
Copy link

also did get the "reset ok" as you can read in my post, but it was not "ok".

@tERB00
Copy link

tERB00 commented Feb 24, 2024

I did this:

  • Connected all the pins including REST_N to Gnd
  • Started the script
  • Pulled off REST_N lead from Gnd

Flashed that way first try with no issues.

@TheNitek
Copy link

That's what I am trying, but It doesn't work even after many, many attempts. I feel like my board might be different in some way ...
PXL_20240224_195804265
PXL_20240224_195740436

@pvvx
Copy link
Owner

pvvx commented Feb 24, 2024

REST_N must be released when the Reset OK message occurs.
Without an RTS signal from the adapter to REST_N, the connection is difficult.

@TheNitek
Copy link

New serial adapter is already on it's way 😀 I hope it works then

@pvvx
Copy link
Owner

pvvx commented Feb 24, 2024

but with " RST shortly pulled to GND" it works.

Linux ? - Everything is crooked there.

yes, never used windoze in 20 years. so linux is my natural OS.

On Linux there are always problems with setting the character reception timeout and RTS/DTR on USB-UART adapters.

@tERB00
Copy link

tERB00 commented Feb 25, 2024

That's what I am trying, but It doesn't work even after many, many attempts. I feel like my board might be different in some way ...

I've got exact the same board. And yes, some usb adapters doesn't work with some devices but work with others... I used CH341A programmer in TTL mode on mine.

@TheNitek
Copy link

Different USB2Serial worked the first time, even though I did the reset manually.

@electro-nic
Copy link

Hi! yesterday I flashed the sensor and I would like to set the advertising period to 1 min as on xiaomi but max value 10000
photo_2024-03-03_08-47-17

@electro-nic
Copy link

Firmware 1.6
8:52:06: Поиск устройств
08:52:28: Ожидание соединения с BTH01-DB601F
08:52:38: Model: BTH01
08:52:38: Firmware: github.com/pvvx
08:52:38: Hardware: 0014
08:52:38: Software: V1.4
08:52:38: Device info # hw: 0014, sw: 0014, services: 00004398, sd: 0000
08:52:38: Устройство подключено.
08:53:10: Установка времени на устройстве (23763AE465)...

@draekko
Copy link

draekko commented Mar 15, 2024

Just an FYI for future readers of this issue thread, in my case with my serial adapter i had to tap REST_N to ground to get it working instead of just going straight to ground and then releasing like was suggested. Was using an older cp210x adapter.

@pvvx
Copy link
Owner

pvvx commented May 9, 2024

BTHome is the only open standard with a registered UUID and paid for in the Bluetooth SIG by Allterco.
https://bthome.io/images/License_Statement_-_BTHOME.pdf
Register and pay for the UUID for ATC1441, then I’ll turn it on.

@strix-iwan
Copy link

подпаял pl2303 а что дальше не понял - где скрипт прошивки ? Какой программой шить?

@strix-iwan
Copy link

strix-iwan commented Oct 2, 2024

как понять что прошилось ? что то еще не так сделал?
Снимок экрана 2024-10-03 002543

@strix-iwan
Copy link

значит никто не подскажет (( жаль

@pvvx
Copy link
Owner

pvvx commented Oct 8, 2024

У вас нелады с Python.
В Windows обычно используется python.exe вместо python3.

@xyzzy42
Copy link

xyzzy42 commented Oct 19, 2024

The script has been fixed to work on Linux.

The copy in bthome_phy6222/rdwr_phy62x2.py is fixed, but there is a second copy in ota_boot/rdwr_phy62x2.py, this other copy is not updated and still opens and closes the serial port when changing baud rate.

@edwardtich1
Copy link

Connecting...
PHY62x2 - Error Reset!
Check connection TX->RX, RX<-TX, RTS->RESET and Chip Power!

@g6094199
Copy link

tx->rx switch?
NOT rst pulled to gnd?

@edwardtich1
Copy link

edwardtich1 commented Nov 21, 2024

it worked!
thanks a lot!

maybe someone will find it useful

connect RESET and GND

C:\THB2-1.8>python rdwr_phy62x2.py -p COM5 -e -r wh BOOT_BTH01_v19.hex

press enter

PHY62x2 Utility version 11.03.24
---------------------------------------------------------
Connecting...

disconnect RESET and GND

PHY62x2 - Reset Ok
Revision: b'001340c4 6222M005'
FlashID: 1340c4, size: 512 kbytes
PHY62x2 - connected Ok
---- Segments Table -------------------------------------
Segment: 11003000 <- Flash addr: 00003000, Size: 00008b88
Segment: 1fff0000 <- Flash addr: 0000bb88, Size: 00000400
Segment: 1fff1838 <- Flash addr: 0000bf88, Size: 00002bca
----------------------------------------------------------
Erase Flash work area... ok
Segment Table[03] <- Flash addr: 00002000, Size: 00000130
Write 0x00000130 bytes to Flash at 0x00002000... ok
Segment: 11003000 <- Flash addr: 00003000, Size: 00008b88
Write 0x00002000 bytes to Flash at 0x00003000... ok
Write 0x00002000 bytes to Flash at 0x00005000... ok
Write 0x00002000 bytes to Flash at 0x00007000... ok
Write 0x00002000 bytes to Flash at 0x00009000... ok
Write 0x00000b88 bytes to Flash at 0x0000b000... ok
Segment: 1fff0000 <- Flash addr: 0000bb88, Size: 00000400
Write 0x00000400 bytes to Flash at 0x0000bb88... ok
Segment: 1fff1838 <- Flash addr: 0000bf88, Size: 00002bca
Write 0x00002000 bytes to Flash at 0x0000bf88... ok
Write 0x00000bca bytes to Flash at 0x0000df88... ok
----------------------------------------------------------
Write Flash from file: BOOT_BTH01_v19.hex - ok.
Send command 'reset' - ok

@edwardtich1
Copy link

edwardtich1 commented Nov 23, 2024

Now I want to adjust the temperature and humidity values.

Actual info:
Temperature: 25.2 °C
Humidity: 53 %

Sensor info:
Temperature: 22.50 °C
Humidity: 50.00 %

Set values

Sensor parameters CHT8305, I2C Address: 0x40
Correction coefficients
Temperature: 16500
Humidity: 10000

Display correction
Temperature: -4000
Humidity: 0

how can I correct the data?

@pvvx
Copy link
Owner

pvvx commented Nov 23, 2024

The coefficients are specified in the datasheet for the CHT8305 sensor.
The program uses coefficients multiplied by 100.

Datasheet for the sensor CHT8305
https://github.com/pvvx/pvvx.github.io/blob/master/THB2/CHT8305C%20Advanced%20Datasheet%20Ver2.5%202021-10-26.pdf

@edwardtich1
Copy link

Коэффициенты указаны в паспорте датчика CHT8305. Программа использует коэффициенты, умноженные на 100.

Технический паспорт датчика CHT8305 https://github.com/pvvx/pvvx.github.io/blob/master/THB2/CHT8305C%20Advanced%20Datasheet%20Ver2.5%202021-10-26.pdf

I understand. cannot be adjusted. Thank you very much!

@pvvx
Copy link
Owner

pvvx commented Nov 23, 2024

The coefficients are changed in the program PHY62x2BTHome.html.
Use fw "APP", not "BOOT".

@edwardtich1
Copy link

Коэффициенты меняются в программе PHY62x2BTHome.html. Используйте fw "APP", а не "BOOT".

I saw where they were changing
but I don’t understand at all what needs to be changed and what)

@pvvx
Copy link
Owner

pvvx commented Nov 23, 2024

Linear equation with one variable (7th grade school)

@edwardtich1
Copy link

I understand. cannot be adjusted. Thank you very much!

I understand. cannot be adjusted. Thank you very much!

@g6094199
Copy link

Now I want to adjust the temperature and humidity values.

Actual info: Temperature: 25.2 °C Humidity: 53 %

Sensor info: Temperature: 22.50 °C Humidity: 50.00 %

Set values

Sensor parameters CHT8305, I2C Address: 0x40
Correction coefficients
Temperature: 16500
Humidity: 10000

Display correction
Temperature: -4000
Humidity: 0

how can I correct the data?

just to claify:

EVERY senser has its unaccuracies which is expectable and can be retrieved from the datasheets (to bad that chinese oem tend to "optimise" their products for marketing. also is the quality management. so i wont trust +-0.5° for this very cheap CHT8305 sensor. while a sensirion sht4x sensor with +-0.2° cost as much as the whole bht01 module. same for the dht22)!

eg
sensor 1 has +-1,5° (common for very cheap sensors)
sensor 2 has +-0,8° (which is quiet good sensor)
but anyway in worst case sensor 1 has a positve max strung of 1,5° and sensor 2 of -0,8°. so this is a worst case an results in measuring diff of 2,3°. this is near to the values u mentioned and expecable. so i would say there is nothing wrong with the sensors at first sight.

just to adjust the offests you need to know WHICH sensor is wrong...this CANT be done with only 2 sensors.
you need a calibrated sensor or a bunch of uncalibrated good quality senors to measure a mean value. this value should tend to the real/correct value. from there you can do offsets.

@edwardtich1
Copy link

Actual info:
Temperature: 25.2 °C
Humidity: 53 %

calibrated sensor

@pvvx
Copy link
Owner

pvvx commented Nov 23, 2024

calibrated sensor

Measurements must be carried out in a special stable cabinet with constant temperature and humidity. Any convection must be excluded. Temperature and humidity fluctuations must not exceed the accuracy of the results over several hours of measurement. Otherwise, you will not calibrate the sensor.

The battery temperature changes over a long period of time. This affects the sensor, as it is located in a single plastic housing. Therefore, the measurements in the temperature-stabilized cabinet will be equalized only after a couple of hours.

These thermometers react faster to humidity.
Due to different reaction times, the conversion to dew point is not very accurate with temperature fluctuations.

If you compare with a sensor located nearby on the same shelf or on the table - due to convection and other factors the difference can reach more than 2 degrees. This is typical and normal for an ordinary apartment.

Actual info: Temperature: 25.2 °C Humidity: 53 %

Sensor info: Temperature: 22.50 °C Humidity: 50.00 %

Without special equipment such as thermal cabinets, etc., such a difference cannot be calibrated. Since in other conditions there will be an even greater difference...

@pvvx
Copy link
Owner

pvvx commented Nov 23, 2024

EVERY senser has its unaccuracies which is expectable and can be retrieved from the datasheets (to bad that chinese oem tend to "optimise" their products for marketing. also is the quality management. so i wont trust +-0.5° for this very cheap CHT8305 sensor. while a sensirion sht4x sensor with +-0.2° cost as much as the whole bht01 module. same for the dht22)!

CHT8305 is not designed to operate from CR2032.
CHT8305 has a minimum supply voltage of 2.5V and a large delta of readings in the operating voltage range. A stabilized power supply is required.
And the thermometer's voltage supplied by the CR2032 battery changes depending on the load. And the load is pulsed - 6..10 μA and 5..15 mA. As a result, the voltage of a half-discharged CR2032 battery pulses from 3.0 to 2.2..2.6V.

At voltages below 2.5V, the CHT8305 produces jumping, understated temperature readings by tens of degrees...

@g6094199
Copy link

g6094199 commented Nov 25, 2024

Now I want to adjust the temperature and humidity values.
Actual info: Temperature: 25.2 °C Humidity: 53 %
Sensor info: Temperature: 22.50 °C Humidity: 50.00 %
Set values

Sensor parameters CHT8305, I2C Address: 0x40
Correction coefficients
Temperature: 16500
Humidity: 10000

Display correction
Temperature: -4000
Humidity: 0

how can I correct the data?

just to claify:

EVERY senser has its unaccuracies which is expectable and can be retrieved from the datasheets (to bad that chinese oem tend to "optimise" their products for marketing. also is the quality management. so i wont trust +-0.5° for this very cheap CHT8305 sensor. while a sensirion sht4x sensor with +-0.2° cost as much as the whole bht01 module. same for the dht22)!

eg sensor 1 has +-1,5° (common for very cheap sensors) sensor 2 has +-0,8° (which is quiet good sensor) but anyway in worst case sensor 1 has a positve max strung of 1,5° and sensor 2 of -0,8°. so this is a worst case an results in measuring diff of 2,3°. this is near to the values u mentioned and expecable. so i would say there is nothing wrong with the sensors at first sight.

just to adjust the offests you need to know WHICH sensor is wrong...this CANT be done with only 2 sensors. you need a calibrated sensor or a bunch of uncalibrated good quality senors to measure a mean value. this value should tend to the real/correct value. from there you can do offsets.

here we have a nice example from work:

beispiel

in red the calibrated 2,5k€ ahlborn temp sensor. the others are 30€/piece high quality sht85. and you see how crap the sht85 are. many of them, currently i have about 15 of them running, are out of spec. so now think of the 50ct senors we talking about here......

i can show you the same for hum, co2, particel, uv, etc......

@pvvx
Copy link
Owner

pvvx commented Nov 25, 2024

image

image

Thermometers: CGG1M, TS0201 (TS0201S1)

At different speeds of temperature change - different readings. Depends on the speed of heating of the sensor with the elements surrounding it. Plus different air convection on the shelf.

@pvvx
Copy link
Owner

pvvx commented Nov 25, 2024

in red the calibrated 2,5k€ ahlborn temp sensor.

:) MY18B20 price < $0.5 (works from 1.8 to 5V, unlike DS18B20.)

The light graph is an SHT4x and the other two overlapping by 1 bit are two MY18B20:
image
Both MY18B20 in cardboard box.

The sensors are spaced 10 cm apart and the device is not lying on the table:
image

@pvvx
Copy link
Owner

pvvx commented Nov 25, 2024

and you see how crap the sht85 are.

Place and lock all your sensors in a cardboard box and in a closed cabinet.
After a couple of hours, compare the readings.

Lamp as a temperature sensor -> https://www.youtube.com/watch?v=29ytMrnC8eQ

Please remember to ensure that the battery voltage for CHT8305 is greater than 2.5V.

image

CHT8305:
image
image

Real temperature: +22С :)

@pvvx
Copy link
Owner

pvvx commented Nov 25, 2024

Sensor: CHT8310
image

CHT8305:
image

@pvvx
Copy link
Owner

pvvx commented Nov 25, 2024

Devices with the BL55028 display driver chip and the CHT8305 sensor are not recommended for purchase.
These components consume too much power, which leads to rapid battery discharge.
These components are not designed to be powered by batteries. The BL55028 and CHT8305 have a minimum supply voltage limited to 2.5 V. As a result, batteries with an initial voltage of 3 V cannot be fully utilized.

Under the Tuya brand, China sells defective and long-term stored components to other countries. Instead of recycling.

In Tuya's crafts, the flux on the printed circuit boards does not wash off, and if it does, the sensor is not protected. As a result, there are many sensors that react poorly to humidity or give incorrect readings.

An example of such a sensor CHT8305:
The humidity outside is 94..98%. It has not been able to get the correct readings for 18 hours.
But the temperature is approximately correct...
image
There's nothing you can do about it except throw it away.

@luigiserrantoni
Copy link

I just receved an updated version of BTH01, PCB reports version 3.1 and date 2024-10-18. It uses the CHT8320 sensor.

immagine
immagine

I just want to report that firmare v20 works correctly on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests