pvvx / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometers and Telink Flasher
https://github.com/pvvx/pvvx.github.io/tree/master/ATC_MiThermometer
Other
2.94k stars 205 forks source link

[Feature request] Use hardware button to save energy #192

Closed unaiur closed 1 year ago

unaiur commented 2 years ago

Some devices (like CGDK2) have a hardware button that is currently unused.

It can be used to implement optional battery optimizations:

pvvx commented 2 years ago

To do this, you need to create another version. Software algorithms and functionality in the current version are not compatible with this implementation. This is similar to the XMWSDJ04MMC variant. It showed inconvenience in use.

This optimization offers no benefit to battery life, but greatly reduces the functionality and use cases of the thermometer. The average consumption of the TLSR825x SoC itself at default settings (advertising every 2.5 seconds) is 6 uA. The indicator consumes much more. In CGDK2, this is more than 20 µA, LYWSD03MMC - 8..9 µA Disabling the LCD controller is not possible in most cases. To do this, you need to install an additional key to turn off its power. E-Ink does not consume when displayed, but consumes a lot when redrawing. To do this, there is an option for the minimum image refresh interval.

Sensor polling in 10 seconds is chosen as optimal for those who do not know how to set up integration. For smooth control of heating elements (PID control), data must be transmitted every 0.1 seconds. But most integrations and MQTT cannot provide this mode.

When polling for 10 seconds, only such control can be squeezed out of "HA": image image

The "warm floor" has even more inertia. This will cause much larger fluctuations in temperature.

It is not possible to reduce the number of transmissions of duplicate advertisements due to the use of ESP chips by many. They miss a lot of packets when receiving and additional duplication is required. A normal BLE adapter or controller, when surrounded by hundreds of BLE devices, has a loss of about 7%. What not to say about ESP.

pvvx commented 2 years ago
  • Use a larger advertisement interval (1min), but when the button is pressed swap to a short advertisement interval (0.5sec) for 5 minutes or while there is an active BT connection. This mode can be enabled only for devices with a hardware button and for use cases that not require automated connections to the device. It can be also useful to speed up BT connections.

Preliminary analysis of CGDK2(-2) consumption: image image

unaiur commented 2 years ago

I don’t understand you. Are you saying it is worthless because the maximum battery life with a CGDK2 always sleeping is 16 months?

Are you proposing to use a bigger battery? Maybe a CR2450 battery will fit in.

Anyway, reducing the advertising time to less that half a second speed ups the Bluetooth connection and makes it more reliable for Linux users.

Best regards!

On Sat, 12 Feb 2022 at 03:31 Victor @.***> wrote:

  • Use a larger advertisement interval (1min), but when the button is pressed swap to a short advertisement interval (0.5sec) for 5 minutes or while there is an active BT connection. This mode can be enabled only for devices with a hardware button and for use cases that not require automated connections to the device. It can be also useful to speed up BT connections.

Preliminary analysis of CGDK2 consumption: [image: image] https://user-images.githubusercontent.com/12629515/153693123-504c56d9-f078-4355-a9f6-57c21c6afd35.png

— Reply to this email directly, view it on GitHub https://github.com/pvvx/ATC_MiThermometer/issues/192#issuecomment-1036952610, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM4WB2MAI7GAOKDOXUVY7TU2XBAVANCNFSM5OBDAKDQ . You are receiving this because you authored the thread.Message ID: @.***>

pvvx commented 2 years ago

Yes. Sleeping TLSR8253 with RAM enabled consumes 3..3.1 uA. The transmission of advertising with a period of 10 seconds is 3 μA. The temperature sensor also consumes power. But the main consumer in CGDK2 is BU9792. The BU9792 consumes 3 times more than a running TLSR8253 with advertise every 10 seconds. Windows and Android connect to the device without problems at 10 second intervals. Recent versions of Bluez on Linux have also been fixed.

CGDK2 https://www.qingping.co/temp-rh-monitor-lite/overview : Ultra-low Power Consumption, One Button Cell Lasts for 8 Months With Ultra-low power consumption LCD, one button cell can last for 8 months in common indoor environment for Qingping Temp & RH Monitor Lite.

CGDK2-2 (doesn't have BLE): image Rated Power 30 μA Real - over 45 μA.

The pressed button adds 30 uA. These are the values of the resistors in the button circuit. :)

unaiur commented 2 years ago

I implemented the logic to turn on and off the lcd and its controller using the hardware button. Single click => toggles screen using an I2C command. I do not have hardware to measure the impact, but when the screen is off it takes around 25 seconds after removing the battery for the capacitor to drain and CPU to turn off, therefore the battery life should be greatly extended.

mat-c commented 2 years ago

How to you know when cpu turn off ? What is the time with lcd on ?

pvvx commented 1 year ago

Disabling the screen on CGDK2 is implemented in version 4.3