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

phy6222 controller support. #268

Closed
Jarled opened this issue Nov 20, 2022 · 36 comments
Closed

phy6222 controller support. #268

Jarled opened this issue Nov 20, 2022 · 36 comments

Comments

@Jarled
Copy link

Jarled commented Nov 20, 2022

I bought the newer version of this sensor and it seems to be using a PHY6222 controller, could get it working on this please?
http://wiki.phyplusinc.com/doku.php?id=menu:phy62_series:phy6222
20221119_124130
20221119_124148
20221119_124153

@pvvx
Copy link
Owner

pvvx commented Nov 20, 2022

The PHY6222 has a higher consumption (13 uA) than the TLSR825x (1.8 uA) in sleep mode with active SRAM. Also, the PHY6222 software and hardware has an increased SoC wake-up time - the result is an even higher average current.
Thermometers with TLSR825x in combination with an LCD/E-Ink driver and sensor have a sleep current of up to 9 µA.
With PHY6222, battery life will be significantly reduced... Unsuccessful option.


The protective sticker installed for protection during installation has not been removed from the temperature and humidity sensor :)
image

Is this some kind of fake Xiaomi LYWSD03MMC?

@Jarled
Copy link
Author

Jarled commented Nov 20, 2022

i dont think so, its meant to be a Bluetooth 5.0 BLE version
https://www.aliexpress.com/item/1005004865399211.html?spm=a2g0o.order_list.0.0.54e218024YIBU1

@pvvx
Copy link
Owner

pvvx commented Nov 20, 2022

Oh, it's Tuya :)
For Tuya, any hacky manufacturers are produced ...
TLSR825x - Bluetooth 5.0+

@pvvx
Copy link
Owner

pvvx commented Nov 20, 2022

Another "miracle" BLE thermometer CX0726B:
image
It has CR2032, but the average current in ad mode is 80 uA. And when connected to a regular Chinese program, the average current is 0.8 mA. Ten days of battery life :)
Temperature and humidity transfers only when connected. (This is for all Tuya)
image
image

image

@Jarled
Copy link
Author

Jarled commented Nov 20, 2022

i have no experience in this space, if someone can help me remove the bluetooth bind key bit and i can add it to HA.

@pvvx
Copy link
Owner

pvvx commented Nov 20, 2022

Temperature and humidity transfers only when connected. (This is for all Tuya)
"Keys" are usually not required for this.

You can officially get the keys to any Tuya device on their website https://iot.tuya.com/.

You need to register.
1 Cloud - device list… get id
2 API explorer -> Smart Home Management System-> Device Management -> Get device details … Sybmit ... use id

I have not seen integration to HA for Tuya BT/BLE.

@Jarled
Copy link
Author

Jarled commented Nov 20, 2022

Thanks, i got that info now, is there a browser page i can test with the local key ?

@pvvx
Copy link
Owner

pvvx commented Nov 20, 2022

https://www.aliexpress.com/item/1005004865399211.html
I ordered it, I'll see when it arrives.

Thanks, i got that info now, is there a browser page i can test with the local key ?

Use nRF Connect in https://play.google.com
Read UUID values...

@Jarled
Copy link
Author

Jarled commented Dec 2, 2022

did it arrive ?

@pvvx
Copy link
Owner

pvvx commented Dec 3, 2022

Last info in tracking:

Day 5 11/24/2022 18:11:12
Left the country of transit
Day 6 11/25/2022 00:00:00
Loading on the plane
Day 7 11/26/2022 13:15:00
[Hong Kong] Sent
day 13 02.12.2022 00:30:00
Arrived at destination airport

@pvvx
Copy link
Owner

pvvx commented Dec 9, 2022

Got a few pieces half an hour ago. Boxes like that - I took a picture of a couple:
image
Haven't opened the boxs yet :)

@pvvx
Copy link
Owner

pvvx commented Dec 9, 2022

I will post data on TX-05 in https://pvvx.github.io/TH-05/

@Jarled - Why not write about support in HA LocalTuya?

@Jarled
Copy link
Author

Jarled commented Dec 9, 2022

What do you want me to write, have you managed to get it working ?

@pvvx
Copy link
Owner

pvvx commented Dec 9, 2022

TH-05 consumes a lot in operating mode: Average 33.4 uA
After registration in "Smart Life": Average 43.2 uA (!)


Minimum chipset power consumption (sleep mode, datasheet):
PHY6222QC-W04I - 13uA @ Sleep Mode with 32KHz RTC and all SRAM retention
BL55028 - 9 uA
Sensor? - 1 uA?
Total: above 23 uA (A lot for CR2032. Half a year maximum?)
Writing a program for such equipment does not build time. Such products (Tuya) go to the trash.


Smart Life
image
image

@Jarled
Copy link
Author

Jarled commented Dec 9, 2022

Can these be added to Home assistant via BTHome or will it require creating a new program ?

@pvvx
Copy link
Owner

pvvx commented Dec 9, 2022

@pvvx pvvx closed this as completed Dec 9, 2022
@Jarled
Copy link
Author

Jarled commented Dec 9, 2022

ok but what about doing it via ESPHome instead ?
https://esphome.io/components/sensor/xiaomi_ble.html#lywsd03mmc

@pvvx
Copy link
Owner

pvvx commented Dec 9, 2022

No way. It requires creating a new program for PHY6222 and (wired) flashing the thermometer, which is not worth doing for this chipset version. It is not suitable for long work from CR2032.

@pvvx
Copy link
Owner

pvvx commented Dec 9, 2022

When temperature or humidity changes, TH-05 transmits data to BLE advertising encrypted using the Tuya protocol.
HA requires integration that supports BLE Tuya.
custom-components/ble_monitor#1063

@pvvx
Copy link
Owner

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

@cconde
Copy link

cconde commented Jun 5, 2023

We shouldn't expect this great firmware on this device soon, isn't it?

@pvvx
Copy link
Owner

pvvx commented Jun 7, 2023

In this repository and TelinkMiFlasher.html Telink SoC devices are supported.
There is no gcc on the PHY chipset. Only proprietary paid Keil.
That is, there can only be an internal non-public or paid version.
No one is doing Taya BLE (OTA), and there is no interest in doing it alone.

@serpent213
Copy link

TX-05 consumes a lot in operating mode: Average 33.4 uA After registration in "Smart Life": Average 43.2 uA (!)

Minimum chipset power consumption (sleep mode, datasheet): PHY6222QC-W04I - 13uA @ Sleep Mode with 32KHz RTC and all SRAM retention BL55028 - 9 uA Sensor? - 1 uA? Total: above 23 uA (A lot for CR2032. Half a year maximum?) Writing a program for such equipment does not build time. Such products (Tuya) go to the trash.

According to the datasheet the RAM is split up into three blocks (32kB + 2 x 16kB) that can be switched off individually. So with only 16kB enabled I would expect a power consumption of 1uA + 1/4 * (13uA - 1uA) = 4uA. So for the whole device 4uA + 9 uA + 1uA = 14uA. Sounds reasonable?

@serpent213
Copy link

The actual money shot:

TH05 PCB LCD side

@pvvx
Copy link
Owner

pvvx commented Jul 1, 2023

According to the datasheet the RAM is split up into three blocks (32kB + 2 x 16kB) that can be switched off individually. So with only 16kB enabled I would expect a power consumption of 1uA + 1/4 * (13uA - 1uA) = 4uA. So for the whole device 4uA + 9 uA + 1uA = 14uA. Sounds reasonable?

Cycle 2.5 sec:
14 uA sleep mode - 2495 ms
6 mA active mode - 5 ms (аctually more *)
( 6 * 5 + 0.014 * 2495 ) / 2500 = 0.025972 mA

  • The measurement time of the AHT 20 sensor is from 80 ms (AHT20 Product manuals). The original firmware uses 102 ms.

image

102 ms ->

image

If we recalculate the specified values in the "AHT20 Operating Manual" for a polling period of 10 seconds, then only the AHT20 sensor will consume at least 5 µA. In reality, according to measurements, it turns out more.
PHY62xx/ST17H66 chips take a long time to wake up from sleep. This is due to the code in the SDK. This increases the time of the active SoC mode. As a result, consumption increases a little more (when compared with other BLE SoC).

As a result (according to theoretical calculations), if the BLE advertising interval of 2.5 seconds is used, the sensor is polled every 10 seconds and 16 kilobytes of RetRAM, the average consumption will be approximately 31 µA .

@Monacoslo
Copy link

So conclusion is?

@almirus
Copy link

almirus commented Dec 15, 2023

@pvvx How long did the device ultimately last on battery?

@NeoMatrixJR
Copy link

In this repository and TelinkMiFlasher.html Telink SoC devices are supported. There is no gcc on the PHY chipset. Only proprietary paid Keil. That is, there can only be an internal non-public or paid version. No one is doing Taya BLE (OTA), and there is no interest in doing it alone.

Looks like there's Community Edition of Keil - can you not release code using community edition as open source? https://www.keil.arm.com/community/

@pvvx
Copy link
Owner

pvvx commented Jan 7, 2024

Everything has already been decided. For PHY62x2, GCC sources are collected with RF library sources.
An implementation for GCC will be available soon at https://github.com/pvvx/THB2.
Currently, this repository contains a test version only for Keil.

@pvvx
Copy link
Owner

pvvx commented Jan 7, 2024

https://github.com/pvvx/THB2 обновлен для сборки в GNU Arm Embedded Toolchain.

Looks like there's Community Edition of Keil - can you not release code using community edition as open source? https://www.keil.arm.com/community/

HTTP ERROR 451

@almirus
Copy link

almirus commented Jan 7, 2024

HTTP ERROR 451

нужен впн

@pvvx
Copy link
Owner

pvvx commented Jan 7, 2024

нужен впн

Обойдется. Мне Keil не нужен.
Обошли - китайцы дали исходники для либ и теперь можно собрать в GCC.
Но всё последующее ПО (типа OTA) для PHY62x2 будет только на русском языке.

@pvvx
Copy link
Owner

pvvx commented Jan 24, 2024

Первая тестовая версия уже на https://github.com/pvvx/THB2
Все обсуждения туда.

@mr-aleks
Copy link

mr-aleks commented Feb 6, 2024

Возможно ли что то сделать вот с таким датчиком pvvx/ZigbeeTLc#53 ? Чип TLSR8250 и SH40. Если нужна еще какая то информация, предоставлю, все что потребуется. :) Хотелось, бы его как то подружить с HA, а то, все что смог найти интеграции "tuya ble" - не работают с ним...

@pvvx
Copy link
Owner

pvvx commented Feb 6, 2024

Возможно ли что то сделать вот с таким датчиком pvvx/ZigbeeTLc#53 ?

У меня такого нет. Ради одного датчика никто шевелиться не будет, только если сами возьмете исходные коды и поправите под свой вариант.

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

8 participants