atc1441 / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometer LYWSD03MMC and Telink Flasher via USB to Serial converter
2.72k stars 460 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.

uncompteabcd commented 2 months ago

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

Yep. Downgraded one 1.4 and four 1.5 devices

Had no luck on macOS. But Linux Ubuntu 22.04.4 LTS with CH340G driver from driver, USB flasher from Aliexpress and Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0130.bin worked for me (hardware v1.5, gnd, 3,3v, pin 14). only flashing on time at 460800 and Atime: 3sec. driver CH340G install on Linux tutorial had to add sudo usermod -a -G dialout <USER> (logout or reboot) for the flasher on Chrome to open/dev/ttyUSB0 (ch340)

mrzocker88 commented 2 months ago

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

  • gnd to gnd
  • tx to P14
  • with battery inserted. image image image

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

Awesome! Thank you very much! Works well.

Edit: Hardware version 1.4

Edit2: 14 thermometer all version 1.4 working well :) Next Mod is to use two AA battery to power them for ever...

rucknapucknavitz commented 2 months ago

Amazing, I received 10 unicorns today - hardware B1.5 and still on the 1.0.0_0130 firmware. Sticker on the box suggests 2024.01 manufacture date. They’re still out there, I guess! I was prepared to go this route - thanks for all the tips above.

citizenjc commented 1 month ago

Hello, just in case someone is attempting flash the firmware with a ESP8266/ESP32, some feedback:

  1. Shorting EN and GROUND is absolutely the way
  2. For two days I wasn't able to get any data to pass to the chip, until I tested the python flasher and saw the error about "Chip sleep? RTS-RST", which made me search more deeply and find out I needed to short the RESET pin (or just press the RESET button) during activation.
  3. I attempted a read from the python flasher, timing the reset, with 5 seconds delay, and it worked!
  4. Then with the web flasher and 8 seconds wait I flashed it successfully, by pressing reset on esp8266 1 or 2 seconds after flash started.
  5. I did this using the schematic with resistor with both TX and RX connected to pin14 and it worked, but i'm pretty sure it's not related to that. In any case, if you can't do it, try that
GaryJS3 commented 1 month ago

My pack of LYWSD03MMC came brand new with 2.11 installed, date code 2023.11. However, it is pretty easy to resolve, I saw some people flashing older OG firmware a few times then doing the custom OTA... not sure why. But I am able to just use a CH340 (worth just picking it up, 5 Pack for $10 USD on Amazon 2Day) and flash the ATC_v47.bin firmware directly, works first time (3 sensors done so far). I found just the 3 pins (3V, GND, P14) were all that I needed, I used clips on the 3V and GND since you can directly go to the battery leads, but I ended up soldering P14 since that was easier and less annoying then trying to keep it perfectly held on by hand. Flashed using the web flasher.

In case someone just wants to flash a 2.1.1 sensor with the custom PVVX firmware, this is what I did:

  1. Open up the sensor, I just took off the back to expose the entire board.
  2. Connect 3V and GND to the battery terminals
  3. Solder or hold your CH340's TX pin to the P14 test pad.
  4. Go to the web flasher
  5. Open your comm port
  6. Select your custom firmware, in my case; ATC_v47.bin
  7. Flash it with default settings
  8. Connect to it with the web flasher: ATC1441 or PVVX IMG_20240510_212938

Extra details: I set them up with minimal issue in Home Assistant when setting the protocol to PVVX (Custom) and using an ESP32 with OpenMQTTGateway.

littlesmithsro commented 1 month ago

Hello, just in case someone is attempting flash the firmware with a ESP8266/ESP32, some feedback:

  1. Shorting EN and GROUND is absolutely the way
  2. For two days I wasn't able to get any data to pass to the chip, until I tested the python flasher and saw the error about "Chip sleep? RTS-RST", which made me search more deeply and find out I needed to short the RESET pin (or just press the RESET button) during activation.
  3. I attempted a read from the python flasher, timing the reset, with 5 seconds delay, and it worked!
  4. Then with the web flasher and 8 seconds wait I flashed it successfully, by pressing reset on esp8266 1 or 2 seconds after flash started.
  5. I did this using the schematic with resistor with both TX and RX connected to pin14 and it worked, but i'm pretty sure it's not related to that. In any case, if you can't do it, try that

Hi, can you elaborate how to connect and flash esp32 to sensor? Thank you

citizenjc commented 1 month ago

Hello, just in case someone is attempting flash the firmware with a ESP8266/ESP32, some feedback:

  1. Shorting EN and GROUND is absolutely the way
  2. For two days I wasn't able to get any data to pass to the chip, until I tested the python flasher and saw the error about "Chip sleep? RTS-RST", which made me search more deeply and find out I needed to short the RESET pin (or just press the RESET button) during activation.
  3. I attempted a read from the python flasher, timing the reset, with 5 seconds delay, and it worked!
  4. Then with the web flasher and 8 seconds wait I flashed it successfully, by pressing reset on esp8266 1 or 2 seconds after flash started.
  5. I did this using the schematic with resistor with both TX and RX connected to pin14 and it worked, but i'm pretty sure it's not related to that. In any case, if you can't do it, try that

Hi, can you elaborate how to connect and flash esp32 to sensor? Thank you

Not much else I can say really, short esp pins EN to a GND, TX to pin 14, connect via USB, web flasher, trial and error. Unless you have some specific doubt?

mucden commented 1 month 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

This method has worked for me with B1.4, thank you. I've used this fellow: IMG_1313

flexisss commented 2 weeks ago

This method has worked for me with B1.4, thank you. I've used this fellow: This method also worked on HW V1.5, SW 2.1.1 Today I downgraded the version and updated it to firmware that supports ZIGBEE

praneeth03 commented 2 days ago

Maybe I can't differently, but flash by site only works on Windows "machine". On MacBook I bricked by flash. On Windows "machine" I recovery firmware without problems :)

Can confirm this - flashing (atleast via web) bricks the device on MacOS (it works perfectly on Windows). Also like @pvvx mentioned only 3 wires are needed for flashing - Gnd to Gnd, Vcc to 3.3v and P14 to TX on serial adapter. Like someone else mentioned, I was able to pull this off without soldering but I had all types of dupoint connectors at my disposal.

In hindsight this was easy enough to do (thanks to @pvvx @atc1441 and others), but the fact that it didn't work on Macbook made me spend a few hours trying to figure this out (somethings are just weird on Macs).

js4jiang5 commented 1 day ago

Maybe I can't differently, but flash by site only works on Windows "machine". On MacBook I bricked by flash. On Windows "machine" I recovery firmware without problems :)

Can confirm this - flashing (atleast via web) bricks the device on MacOS (it works perfectly on Windows). Also like @pvvx mentioned only 3 wires are needed for flashing - Gnd to Gnd, Vcc to 3.3v and P14 to TX on serial adapter. Like someone else mentioned, I was able to pull this off without soldering but I had all types of dupoint connectors at my disposal.

In hindsight this was easy enough to do (thanks to @pvvx @atc1441 and others), but the fact that it didn't work on Macbook made me spend a few hours trying to figure this out (somethings are just weird on Macs).

I was waiting for @pvvx to release the version that support 2.1.1 devices, but it's been 9 months, I guess it's not possible. Therefore I decided to do it myself with ESPHome last month. Add AES decrypt function to extract the temperature, humidity and battery level from advertised data, then use MQTT to send the info back to HA. It works well, but the downside is the data update period is as long as 10 minutes. Well, from another point of view the battery will last longer, not bad at all. At least I don't have to flash with wire.

pvvx commented 1 day ago

Add AES decrypt function to extract the temperature, humidity and battery level from advertised data, then use MQTT to send the info back to HA

https://www.home-assistant.io/integrations/xiaomi_ble

It works well, but the downside is the data update period is as long as 10 minutes.

The thermometer with Xiaomi firmware still transmits every 1.6 or 2 seconds, but not temperature and humidity data, but registration information.

I was waiting for @pvvx to release the version that support 2.1.1 devices, but it's been 9 months,

As described, I’m waiting for a new version to scan the new authorization protocol. MiHome's user agreement prohibits code reverse engineering.

hashier commented 13 hours ago

scan the new authorization protocol

Will this be done with sniffing the bluetooth traffic in wireshark or what is the way to do this?

pvvx commented 11 hours ago

Will this be done with sniffing the bluetooth traffic in wireshark or what is the way to do this?

Yes, in Wireshark, as version 2.1.1_0159 will update...