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

Support new Tuya BLE? #1063

Open
pvvx opened this issue Dec 9, 2022 · 13 comments
Open

Support new Tuya BLE? #1063

pvvx opened this issue Dec 9, 2022 · 13 comments

Comments

@pvvx
Copy link

pvvx commented Dec 9, 2022

Some new Tuya devices with BLE transmit data in an encrypted format.

For example TH-05:
When temperature or humidity changes, TH-05 transmits data to BLE advertising encrypted using the Tuya protocol (using additional advertising packages). If there are no changes, a typical BLE advertisement with device identification data is transmitted.
image

LocalTuya can receive Authorization Key and other codes from Cloud (and includes a description of the device)...

@pvvx
Copy link
Author

pvvx commented Dec 23, 2022

##Advertising packages:

UUID 0xFD50 - TUYA BLE PROTOCOL VERSION 4

type Flag UUID 02 UUID 16 UUID 16 Data
msg 020106 030250fd 141650fd 488040000001b36eb30d64e80a4d9cbc38
adv 020106 030250fd 141650fd 490000080c9c105bc01d9f87

adv - always transmitted.
msg - transmitted when temperature and/or humidity changes.

##Adv contains:

before bond - device pid, after bond - encrypted device_id with login_key and device_id

##Packet bytes, except for standard identifiers, are formed as follows:

[7] pid_len+7
[11,12] Frame Control: bound_flag |0x08, DEVICE_SHARED |0x04, connect request bit |0x02
[13] pid_type
[14] pid_len
[15...] code

Clarification https://github.com/tuya/tuya-ble-sdk/blob/main/sdk/src/tuya_ble_main.c#L453

@Ernst79
Copy link
Collaborator

Ernst79 commented Jan 8, 2023

Thanks for the info. I'm afraid this will be difficult (for me) to add. Will give it a try later.

I assume temperature and humidity are in [15...] code, after decryption.

@pvvx
Copy link
Author

pvvx commented May 28, 2023

Another thermometer with Tuya BLE - MHO-C122 (2AWMOMHOC122).

fcc.report

@fliespl
Copy link

fliespl commented Jun 12, 2023

@pvvx have you had any luck?

@ant-thomas
Copy link

Any luck with getting data out of the TH05?

They're now available very cheap on the AliExpress Choice Day Sales - which is why I now own one.

@NeoMatrixJR
Copy link

Following. I bought some of these thinking they were the same as the old ones I have that work just fine with BLE sensor in HA proxied through ESPHome. I didn't see they were new models :(

@pvvx
Copy link
Author

pvvx commented Dec 23, 2023

For the "THB2" sensor, the only solution so far is to reflash it in the PhyPlusKit program, using the files from https://pvvx.github.io/THB2/
Test firmware files for working in BTHome format.
image
This is not a full version - only temperature and humidity are transmitted every 2.5 seconds.
Updates are possible in the future.

@asmsaifs
Copy link

@pvvx Do you have a functional download link for the PhyPlusKit software? I came across a link, but unfortunately, it's no longer operational!

@pvvx
Copy link
Author

pvvx commented Dec 23, 2023

https://github.com/pvvx/PHY62x2/tree/master/PhyPlusKit
I have all the SDKs from PHY, but they can be found by searching on github.
The test firmware is based on sources from https://github.com/biemster/st17h66_FindMy
They had previously worked on optimizing consumption and these developments were used.

@asmsaifs
Copy link

@pvvx Thank you very much for the resources. Keep up the great work!

@pvvx
Copy link
Author

pvvx commented Feb 21, 2024

Custom firmware for Tuya devices on the PHY622x2 chipset to work in the BTHomeV2 format.

image

@Ernst79
Copy link
Collaborator

Ernst79 commented Feb 21, 2024

great work, thanks!!

@techprolet
Copy link

Custom firmware for Tuya devices on the PHY622x2 chipset to work in the BTHomeV2 format.

image

This is great! Thank you!
When flashed, is the device openly accessible? I would like to skip esphome altogether and just read the sensor data from an ESP32/Arduino (not EspHome).

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

7 participants