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.93k stars 205 forks source link

Unreliable firmware OTA uploads #190

Closed unaiur closed 2 years ago

unaiur commented 2 years ago

Firmware uploads are quite unreliable. Some times it takes two minutes, other times it takes two hours and most of the time are interrupted.

Is there any setting that can make OTA uploads more reliable?

pvvx commented 2 years ago

On an Android smartphone that is 5 years old, the loading time is 90 seconds. On an old PC (AMD Phenom(tm) II X6 1090T Processor):

01:56:39: Searching for devices
01:56:56: Connecting to: ATC_0B5EED
01:57:18: Hardware Revision String: B1.4
01:57:18: Detected custom Firmware
01:57:18: Hardware Version: LYWSD03MMC B1.4, Software Version: 3.5, Sensor: SHTC3
01:57:18: Custom config: [5, 0, 0, 0, 40, 4, 169, 124, 49, 184, 60]
01:57:24: File size: 63716 bytes
01:57:24: Count: 3983
01:57:25: Start DFU
01:58:05: Update done after 38.914 seconds
01:58:15: Disconnected.

On new PCs - 18..35 seconds.

The PC has a dependency on the USB-BT adapter. Of those tested, the difference is up to 1.5 times.

pvvx commented 2 years ago

I took for the test "Redmi Note 7" (release date 2019): image

unaiur commented 2 years ago

I have tested in a Linux laptop and in an old Windows tablet. Both using integrated Bluetooth controller. Windows tablet is much more reliable but still fails about half of the times.

pvvx commented 2 years ago

This may mean that an adapter with a BT 4 chip is used. It has a low transmitted power and a limited reception range, designed for a working distance of a couple of meters. Changes in the BT 5 for BLE standard provide for an increase in the transmitted power and dynamic range of the receiver, which allows to significantly increase the working distance.


Here are the factors that affect the speed and reliability of an OTA update:

  1. Using a bluetooth adapter with a chip released after 2016 (according to BT v5.0 standards).
  2. Normal battery in a thermometer.
  3. Javascript processing speed in Chrome Explorer on the used device for OTA.

What do you propose to change from this list?

unaiur commented 2 years ago

Okay, it seems that connection is super slow, I got impatient and retried. After retrying it became impossible to connect again. I had to remove the battery, wait ~5 minutes and try again.

Now, I wait until the device connects. sometimes it can take up to a minute, but it almost always connect.

pvvx commented 2 years ago

The thermometer does not have its own source, to continue working for more than a couple of ms without a battery. Accordingly, the problem is in the BT adapter or its driver.

But there is one case - if the battery drops below 2 V, then the SoC in the thermometer is programmatically transferred to deep sleep for 2 minutes. https://github.com/pvvx/ATC_MiThermometer/blob/master/src/app.c#L301 At the same time, the TLSR825x consumes very little and can be powered from any input or delivered capacitor. But this time does not even reach a second - there are other consumers on the thermometer board.

unaiur commented 2 years ago

This thermometer has a large capacitor… it keeps working for 5-6 seconds after removing the battery. But of course, the problem are somewhere else, most likely in the drivers.

On Thu, 10 Feb 2022 at 21:06 Victor @.***> wrote:

The thermometer does not have its own source to keep working for more than a couple of ms. Accordingly, the problem is in the BT adapter or its driver.

— Reply to this email directly, view it on GitHub https://github.com/pvvx/ATC_MiThermometer/issues/190#issuecomment-1035441516, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM4WB3G2DF5GZWFQSAHM4LU2QLE5ANCNFSM5NXUGMQA . You are receiving this because you modified the open/close state.Message ID: @.***>

pvvx commented 2 years ago

CGDK2 image JJ8E - ? uF CGDK2-2 image