atc1441 / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometer LYWSD03MMC and Telink Flasher via USB to Serial converter
2.71k stars 458 forks source link

Xiaomi has released new 2.1.1 firmware #298

Open micturkey opened 9 months ago

micturkey commented 9 months ago

image It seems that the way to update firmware using telink flasher has been forbidden.

pvvx commented 6 months ago

Requires chip restart/reset during "activation". For any programmer. For Telink BDT it’s the same, but even more difficult. How you provide it is your task. By turning off the power, turning off all extraneous sources, or by shorting the RST pin of the TLSR825x chip itself to GND.

The chip should start while sending the “Activation” code.

In other cases, the chip can be in sleep mode and powered from any source (including all its pins) with currents of 1 µA. And in “sleep” mode, the chip has all interfaces disabled and does not perceive anything.

In addition, if you have recorded something unknown, then the SWS chip output can be disabled in this program. But will always be connected for a short time after restarting/resetting the chip.

jjvelar commented 6 months ago

Hi! Any news on LYWSD03MMC with firmware version: 2.1.1_0159? I just can't connect. Pop up message says: "couldn't find any compatible device". Thanks in advance for your help.

pvvx commented 6 months ago

Hi! Any news on LYWSD03MMC with firmware version: 2.1.1_0159?

We are waiting for the popularity of Xiaomi LYWSD03MMC to fall, sales and prices to fall. :) Until Xiaomi deigns to provide an open OTA.

Siemens' mobile once staged a similar encryption race in an attempt to ban custom modifications. This is where the popularity of unlockable models ended. The result is known - Siemens no longer produces phones. :P And there are many such examples over the past 40 years. They tried to do the opposite effect in Espressif, but they could not do it properly... Although their takeoff was ensured by proactive users.

There will always be a smarter competitor. Tuya already offers descriptions, keys and other information to all registered users.

jjvelar commented 6 months ago

Thanks for replying @pvvx Any good tutorials on how to roll back to a previous firmware version? I'm pretty much a newbie. Thanks in advance.

Rawi666 commented 6 months ago

Thank you all very much! I successfully downgraded the firmware without soldering! I ordered a cheap USB-TTL converter. I used left hand to hold steadily VCC and TX pin (near P14/P10 hole on the PCB), it took me a minute practice to stabilise it. Then I set the flash timer to have 8 seconds delay, I clicked flash and then within 8 seconds I grabbed my right hand and holded GND pin :-D After 42 seconds holding hands steadily I was able to finish flashing successfully. No soldering needed guys! I think even if you screw the flashing you can start over and reflash from a broken software, but someone would need to confirm it :)

pvvx commented 6 months ago

I think even if you screw the flashing you can start over and reflash from a broken software, but someone would need to confirm it

Reprogramming can be launched a thousand times. This will not even reduce the Flash resource, since the manufacturer guarantees more than 100 thousand rewritings. image

My trials of various programs on one of the Xiaomi Lywsd03mm have long exceeded a couple of thousand flash overwriters. It works and is used for debugging. A normal programmer with a hardware Telink SWire writes a firmware for a couple of seconds.

ffries commented 6 months ago

After flashing The Xiaomi with OTA, the display does not show and the thermometer does not announce itself even after shorting pins. Does it mean that the XIaomu is bricked?

Can I use any USB-TTL adapter to flash the device?

pvvx commented 6 months ago

After flashing The Xiaomi with OTA, the display does not show and the thermometer does not announce itself even after shorting pins. Does it mean that the XIaomu is bricked?

Firmware for OTA version 2.1.1?

Symbiot78 commented 6 months ago

chiming in with the same 2.x firmware issue. Hoping everything "we" are waiting for will come out soon :-) Keep up the great work!

Hubszo commented 6 months ago

Hi, I have Qingping CGDK2 (round one), which was previously successfully flashed with custom firmware 4.5. Yesterday I OTA flashed it with Zigbee Firmware: ZCGDK2_v0119.bin with Telink Flasher to convert from BLE to Zigbee, and everything went ok according to the log, but now the sensor is stuck on -39°C and 100% humidity. Resetting by button or battery removal didn't help. Any ideas???

pvvx commented 6 months ago

Any ideas?

Flash back to BLE using Zigbee OTA.

ZCGDK2_v0119.bin

This doesn't exist yet. There is ZCGDK2_v0118.bin

Hubszo commented 6 months ago

That was my typo. I meant 0118.bin, of course.

pvvx commented 6 months ago

About Zigbee OTA, see https://github.com/pvvx/ZigbeeTLc

apeelme commented 5 months ago

What did I do wrong when flashing? Nothing is shown on the display after I used https://pvvx.github.io/ATC_MiThermometer/USBCOMFlashTx.html to flash.

My connection from the UART-TTL USB Adapter to the thermostat was like this. TX -> P14 GND -> GND 3V3 -> V+

I tried several times to flash the original firmware but also the zigbee version. Erase all Flash didn't help either

Same happend with me. :(

gjesch commented 5 months ago

I have two issues with the Xiaomi LYWSD03MM (I ordered 4 of them plus 1 CGDK2. Unfortunately I upgraded 2 of them to 2.1.1, well ...)

(A) I flashed with the UART method the ZigBee firmware 1.0.6 from https://github.com/devbis/z03mmc/releases to 1 device (1 out of the 4 devices). The device hardware works OK, but ZHA just updates the temperature. The humidity stays fix on 50%. I will report this on devbis/z03mmc/discussions as well: https://github.com/devbis/z03mmc/discussions/104#discussion-6041570. Just in case anyone has already observed such a behaviour.

(B) I want to stay on BLE for the other 3 devices in order to compare battery life and overall experience. Therefor I have to downgrade to Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin again, or flash ATC_v38.bin right away.

But although I see these firmware versions being used in various screenshots - also on this page - I get the message "Select file is no telink firmware .bin"

image

I must obviously be missing something, but what? Thanks for any advice.

[Update:] Soldered the wires to the CGDK2 in the meantime. I get the same message "Select file is no telink firmware .bin" for both firmware variants:

  1. ZCGDK2_v0118.bin and
  2. CGDK2_v46.bin
pvvx commented 5 months ago

@gjesch - Download the files correctly: ATC_v38.bin - there is no such file. ATC_v46.bin - 82612 bytes CGDK2_v46.bin - 82708 bytes Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin - 92868 bytes

To flash Xiaomi LYWSD03MMC in BLE, in the file selection menu, paste the line:

https://github.com/pvvx/ATC_MiThermometer/raw/master/ATC_v46.bin
gjesch commented 5 months ago

@pvvx thank you for the prompt reply.

The link you provided showed me, what I did wrong.

I right-clicked the *.bin link in the main repository and chose "save link as". After the proposed filename for the download was exactly the same as the visible link, I thought this is the file. Very embarassing in the end, lack of Github knowledge on my side :-/.

Apologies.

xuebinshushu commented 5 months ago

Hi, I just made the same mistake as everyone here. I bought two of these sensors and was planning to flash them and use them with a BLE Tracker on my Home Assistant. However, curious to see how it works originally I did the firmware upgrade when added to mihome app.... stupid curious... So, after sharing my disgrace... How hard is to get one of this USB-COM board and use it to downgrade? any link from Aliexpress? I get little confused about which board is compatible, which link should be used to do the downgrade, how is the right way to wiring... Please, can anyone share where to buy this USB-COM and a step-by-step how to downgrade the firmware ?

Hi. Downgraded using this ch340 usb to ttl rs232 converter: https://www.aliexpress.com/item/32354359382.html?gatewayAdapt=glo2isr Solder p14 on thermometer to txd Solder Gnd to gnd Solder + to 3.3V Flash using: https://pvvx.github.io/ATC_MiThermometer/USBCOMFlashTx.html

Thank you. I have successfully downgraded Xiaomi Thermometer 2 using CH340 as you said.

image 7a814874c741a87eca8d38c1893cd64

makarva79 commented 5 months ago

Привет! Есть новости по LYWSD03MMC с версией прошивки: 2.1.1_0159?

teslabol77 commented 5 months ago

I am getting a blank display now as well. I used Mac OS and tried doing it on my PC and no luck. I am not getting any errors during flash.

yasars commented 5 months ago

flash Ok but after Telink flasher connect it say V.2.1.1_0159 ... but i flash v1 succecfull any idea?

18:54:57: USB-COM opened. 18:55:01: File was selected, size: 92868 bytes 18:55:02: Reset DTR/RTS (100 ms) 18:55:02: Activate (3 sec)... 18:55:05: Write 92868 bytes in to Flash... 18:56:52: Done (109.597 sec). 18:56:52: Soft Reset MCU

lytslimer commented 4 months ago

flash Ok but after Telink flasher connect it say V.2.1.1_0159 ... but i flash v1 succecfull any idea?

Same error! Hardware rev. B2.0. Делал два раза - прошивка не меняется :(

yasars commented 4 months ago

Use FTL232 flasher it works... I have a blank display ...after buy an ftl232 red flasher , i solder pin16,ground,v+ and reset ... And go on windows pc and tadaaaa downgrade sucessfull....

Vovanchik commented 4 months ago

Windows PC is crusial!!! Downgrading doesn't work on Mac.

lytslimer commented 4 months ago

Use FTL232 flasher it works... I have a blank display ...after buy an ftl232 red flasher , i solder pin16,ground,v+ and reset ... And go on windows pc and tadaaaa downgrade sucessfull....

I have CH340G USB to TTL and windows PC. Can you give an aliexpress link? One more month to wait :( v+ and reset?

yasars commented 4 months ago

I have buy it from german ebay... Ch340G dosnt work....

lytslimer commented 4 months ago

I'm flashed it with CH340G! Now I connect it to PC without USB concentrator, directly to PC and it works.

yasars commented 4 months ago

I have no chance with ch340G after flash black screen ... Ftl232 works better... Nice you have luck :)

dbarwikowski commented 4 months ago

I've got lucky adding it to HA.

Repro steps: Added sensor to Xiaomi Home app. Extracted BLE token using: Token extractor Connected device and did activation on Telink Flasher Added it in HA and when it asked for token I've put token from Token extractor and it was happy with it.

kr3st1k commented 4 months ago

I've got lucky adding it to HA.

Repro steps: Added sensor to Xiaomi Home app. Extracted BLE token using: Token extractor Connected device and did activation on Telink Flasher Added it in HA and when it asked for token I've put token from Token extractor and it was happy with it.

  • I've might removed battery at some point but can't recall when exactly

did you entered the BLE key in Telink flasher? i tried to enter manually values from Token Extractor, but it did not wanted to do flash because "do activation" (2.1.1)

dbarwikowski commented 4 months ago

@kr3st1k no, I only have one device and when it connected to HA I didn't want it to disconnect. I am waiting for another one so I can tinker with it later.

pvvx commented 4 months ago

When you enter the keys from MiHome in TelinkMiFlasher.html, the login is processed. But the firmware will not work, although it will be transferred. The check occurs after transferring and recording the new firmware in Flash. The firmware verification keys are not included, but only the login is entered. After transferring and recording the new firmware, a check occurs and the compliance flag is set. But the criteria are not met and the successful OTA flag is not set.

The new flashed fw will not start, but will be erased upon startup. And version 2.xx will start

The MiHome firmware works in HA if you enter the bindkey into the MiHome integration.

dbarwikowski commented 4 months ago

@pvvx i had problems with bind key from TelinkFlasher or token extractor. This was the only way it worked for me.

pvvx commented 4 months ago

You did not update the firmware, but simply used the integration for Xiaomi. Doesn't need a "token".

Keys can be obtained from the “Xiaomi Gateway 3” integration. image

Moe555 commented 4 months ago

Hello,

Unfortunately I made the same mistake - updating the FW right away to V 2.x... I tried several things to downgrade, but I just can't get it done and don't understand why. Please help :)

I use a FT232RL-based USB-COM Adapter, set to 3.3V. HW Revision of the LYWSD03MMC is B1.5. I connected GND to GND, VCC to Vbat and TX to P14 (w/o resistor, but tried with one as well). (Like shown here.)

Then I flashed it using https://pvvx.github.io/ATC_MiThermometer/USBCOMFlashTx.html (115200 baud, Atime 3s; on Win 11 + Chrome)

and FW file https://github.com/pvvx/ATC_MiThermometer/blob/master/Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin

The output looked promising: 06:07:39: USB-COM opened. 06:07:52: Reset DTR/RTS (100 ms) 06:07:52: Activate (3 sec)... 06:07:55: Write 92868 bytes in to Flash... 06:09:39: Done (107.338 sec). 06:09:39: Soft Reset MCU 06:09:53: USB-COM closed.

But when connecting to the telink flasher (or the Xiaomi app) it's showing that it still has the 2.x FW: (https://devbis.github.io/telink-zigbee/) 06:12:48: Searching for devices 06:12:54: Hardware Revision String: B1.5 06:12:54: Software Revision String: 0159 06:12:54: Firmware Revision String: 2.1.1_0159 06:12:54: Detected Mi device 06:12:54: Connected ...

(I tried several other things as well, but I don't want to bore you :))

What am I doing wrong?

ioukos commented 4 months ago

Please correct me if I'm wrong : To sum up, to install Custom firmware on LYWSD03MMC

pvvx commented 4 months ago

Xiaomi LYWSD03MMC with firmware 2.x.x simply will not update to any OTA version.

At the moment, firmware update version 2.x.x is only available via USB-UART.

You can flash any version via USB-UART.

ebabaj commented 4 months ago

I'm not that familiar with soldering

@vdende No soldering necessary. I connected it like this. I held P14 with my hand.

IMG_0984

sagittarius06 commented 3 months ago

It works great thanks IMG_20240312_222146

Macsim51 commented 3 months ago

Hi,

I don't have a CH340G but I have a ESP32 Wifi/Bluetooth/USB-C in my drawer (never used).

Can I downgrade the firmware with it ? Or I absolutely need a CH340G ?

Thx.

image

devbis commented 3 months ago

@Macsim51 You can use any usb-uart dongle. For the image above there is a usb-ttl converter (square one). Potentially, you can short EN-GND to disable the chip and use tx0/rx0 as UART pins. This approach works for arduino boards and could work for your board.

Kerber0ss commented 3 months ago

Cp2102 usb-ttl is ok for this? IMG_5420

EdNotMurphie commented 3 months ago

Cp2102 usb-ttl is ok for this? IMG_5420

Works very well. I made a "drill a hole" edition. ;-) PXL_20240318_183003025

Moaner2 commented 3 months ago

This method how to perform the OTA with 2.1.1_0159. A) Connect the device https://atc1441.github.io/TelinkFlasher.html B) Activate it C) Load the ATC 4.7 firmware D) Connect and modify settings https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html

Tested on two units HW 1.4 and FW 2.1.1._0159 successfully

Xiaomi LYWSD03MMC with firmware 2.x.x simply will not update to any OTA version.

At the moment, firmware update version 2.x.x is only available via USB-UART.

You can flash any version via USB-UART.

twantythree commented 3 months ago

Dear Friend,

how did you do that? In my case the activation progress won't complete...

This method how to perform the OTA with 2.1.1_0159. A) Connect the device https://atc1441.github.io/TelinkFlasher.html B) Activate it C) Load the ATC 4.7 firmware D) Connect and modify settings https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html

Tested on two units HW 1.4 and FW 2.1.1._0159 successfully

Xiaomi LYWSD03MMC with firmware 2.x.x simply will not update to any OTA version. At the moment, firmware update version 2.x.x is only available via USB-UART. You can flash any version via USB-UART.

dartek66 commented 3 months ago

The method provided by Moaner2 does not work. Probably only via UART this can be done.

1eretoile commented 3 months ago

IMG_20240404_105305 j'ai essayé connecté gnd a gnd txd a P14 3v3 a v+

mais après quand je rallume le thermomètre plus rien a l'écran

perfect-deform commented 3 months ago

Guys, just successfully downgraded using ch340g (no jumper, or resistor. just 2 wires). Connected

UPD works with v1.4 tried v1.5 - failed

UPD 2 nope, flashed rev 1.5 the same way tried to flash with OTA 1.0.0_0130 straightaway. But worked the same way, after first try - blank screen, after second - flashed ok

Step-by-step 1) Connect gnd under battery, tx to p14 and insert battery 2) Choose 460800 and Atime: 3sec 3) Flash OTA 1.0.0_0130 4) DO NOT MOVE :) DO NOT DISCONNECT ANYTHING! 5) Change baud to 115200 6) Flash the same firmware again 7) Now your device is dead 8) Disconnect everything (ch340g too) 9) Update page 10) Connect everything the same way 11) Choose 460800 and Atime: 3sec 12) Flash OTA 1.0.0_0130 13) ... 14) PROFIT

uncompteabcd commented 2 months ago

do your "Step-by-step" work for rev 1.5 ?

Guys, just successfully downgraded using ch340g (no jumper, or resistor. just 2 wires). Connected

* gnd to gnd

* tx to P14

* with battery inserted.
  ![image](https://private-user-images.githubusercontent.com/60361408/319551166-7180b4ba-4498-4d20-9e96-727306fef7b0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTI1OTkxMDYsIm5iZiI6MTcxMjU5ODgwNiwicGF0aCI6Ii82MDM2MTQwOC8zMTk1NTExNjYtNzE4MGI0YmEtNDQ5OC00ZDIwLTllOTYtNzI3MzA2ZmVmN2IwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA0MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNDA4VDE3NTMyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFkYWY4ODRkYzE5YmM2MjBmYzNiY2MxM2E2MWYwMmU5ODg1ZmVlOTMyZTc3ZWJhN2M5YTc4NWU4MWI2ZDQyZTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.il3nMfTJHI3U6_3oMnQvtJi0CI8vQQg5nASMS5muvxI)
  ![image](https://private-user-images.githubusercontent.com/60361408/319550527-f57c381b-d2e1-498a-9ae6-e715a90e329f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTI1OTkxMDYsIm5iZiI6MTcxMjU5ODgwNiwicGF0aCI6Ii82MDM2MTQwOC8zMTk1NTA1MjctZjU3YzM4MWItZDJlMS00OThhLTlhZTYtZTcxNWE5MGUzMjlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLV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XotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.D0DeVlFGcy97eA7MgRLN3Dz4EHk7FYkOfJylaXKex78)

UPD works with v1.4 tried v1.5 - failed

UPD 2 nope, flashed rev 1.5 the same way tried to flash with OTA 1.0.0_0130 straightaway. But worked the same way, after first try - blank screen, after second - flashed ok

Step-by-step

1. Connect gnd under battery, tx to p14 and insert battery

2. Choose 460800 and Atime: 3sec

3. Flash OTA 1.0.0_0130

4. DO NOT MOVE :) DO NOT DISCONNECT ANYTHING!

5. Change baud to 115200

6. Flash the same firmware again

7. Now your device is dead

8. Disconnect everything (ch340g too)

9. Update page

10. Connect everything the same way

11. Choose 460800 and Atime: 3sec

12. Flash OTA 1.0.0_0130

13. ...

14. PROFIT
perfect-deform commented 2 months ago

do your "Step-by-step" work for rev 1.5 ?

Yep. Downgraded one 1.4 and four 1.5 devices