pvvx / THB2

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

Tuya BLE sensor: BTH01 #1

Open user784213 opened 9 months ago

user784213 commented 9 months ago

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 commented 9 months ago

Разработка 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 commented 9 months ago

CHT8305 https://github.com/pvvx/ZigbeeTLc/blob/master/src/sensor_cht8305.c

pvvx commented 8 months ago

Соединения на печатной плате 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 commented 8 months ago

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

theanch92 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

@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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago
USB-UART PCB
RX TX1
TX RX1
RTS REST_N
GND -Vbat
+3.3V +Vbat
g6094199 commented 8 months ago

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 commented 8 months ago

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

Linux ? - Everything is crooked there.

g6094199 commented 8 months ago

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 commented 7 months ago
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 commented 7 months ago

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 commented 7 months ago

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

g6094199 commented 7 months ago

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

tERB00 commented 7 months ago

I did this:

Flashed that way first try with no issues.

TheNitek commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

pvvx commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

electro-nic commented 7 months ago

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 commented 7 months ago

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 commented 6 months ago

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 commented 6 months ago

The script has been fixed to work on Linux.

draekko commented 6 months ago

good to know

gvieiraaa commented 6 months ago

Sorry if I got this wrong, but I can't use OTA first, I have to flash using UART?

And could I do it with a raspberry pi instead of with a uart usb adapter?

pvvx commented 6 months ago

On rPi you need to switch something to output RTS... /boot/config.txt ...

NonPIayerCharacter commented 5 months ago

Have one of those, initially it was with CHT8305, but with original firmware I didn't find a use for it. Later removed 8305, as i needed it as a spare part for something else. Found this firmware, looked through source, and seen that it supports AHT2x. Instead of 8305, soldered AHT21, as they are almost pin compatible (AHT21 lacks AD0 and ALERT pins, instead they are NC), and can confirm that this mod works.

Nikolay-Ch commented 4 months ago

@pvvx - is it not expected to support other data packet formats (for example ATC1441), like for devices on the Telink chipset?

pvvx commented 4 months ago

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 commented 1 week ago

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

pvvx commented 1 week ago

https://github.com/pvvx/THB2/blob/master/README-ru.md#%D0%BF%D1%80%D0%BE%D1%88%D0%B8%D0%B2%D0%BA%D0%B0

strix-iwan commented 49 minutes ago

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