dhewg / esphome-miot

ESPHome components for MIoT devices
Other
16 stars 8 forks source link

Xiaomi Smart Air Purifier 4 Lite - Wiki update #13

Open smogger opened 3 months ago

smogger commented 3 months ago

Any chance to get a bit more details about the Xiaomi Smart Air Purifier 4 Lite steps?

I am trying to get my heads around with the "power on the board" step.

I tried either power on the whole unit (3 beeps from the purifier and not connecting to my UART) - since nowhere mentioned HOW should we power on the board. And also tried directly connecting the 3V from my UART to the ESP32 chip leg (still not connecting somehow for me)

The board layout is slightly different then the previous version, so those guides doesn't really help me with the 4 Lite.

(PS: strange to me that whenever I plug the TX/RX to my UART, the power led lights up on it)

Thank you

helgek commented 3 months ago

I flashed directly on the chip using Sensepeek PCBite while the device wasn't connected to power. Instead I used the 3.3V coming from the UART device. I had tried the test pins before as outlined in the guide but when it didn't work immediately I didn't want to invest more time to figure out this variant, instead I went straight on the esp32 pins. I've already flashed about seven devices like this (mostly yeelight lamps and one other xiaomi light).

image

dhewg commented 3 months ago

Does reading from uart work when the device is running the vendor fw? You should see it logging. That needs to work first, and only then can you attempt to flash a new fw.

In my case, I just powered the whole board with its standard power supply. Powering only the esp would be safer, but not as easy. Powering the esp via your uart ttl adapter might not work, depending on how reliable the power output is (you might get lucky, but assume it's not sufficient).

And is that really another revision of the rmb1 or the newer rma2 version (#14)?

smogger commented 3 months ago

In my case, I just powered the whole board with its standard power supply.

How were you been able to power on the board? In my case when I disassembled I had to unplug the display or the sensor from the board (i dont remember now) otherwise I had not enough space/long cable to remove it from the outer shell to have access to the testpoints. And without the sensor I cannot power on the board as it just beeps 3-4 times and thats it.

smogger commented 3 months ago

Does reading from uart work when the device is running the vendor fw? You should see it logging. That needs to work first, and only then can you attempt to flash a new fw.

Esphome (HA) does such thing? Honestly never tried to read out this way. I programmed blank esps only.

dhewg commented 3 months ago

How were you been able to power on the board? In my case when I disassembled I had to unplug the display or the sensor from the board

Same here, I detached various connectors to get to the board, but reattached them once I disassembled the device. So the wires temporarily had different paths, but the device as a whole was fully functioning.

Esphome (HA) does such thing?

Either firmware will log over uart, but in this case I meant the original vendor firmware. It's just to confirm that uart is working. Because if it's not there's no way you can flash another firmware over uart (duh ;)

smogger commented 3 months ago

Worked like a charm. Thanks

Some info to others: You do need to short the filter detector, otherwise it refuse to boot at all and cant flash the ESP (the display part doesn't needs to be plugged) The first boot seems to me a bit slow or something I mean the Wifi connection, so be patient. I had to plug everything together (including the Display) in order to connect for me to my WiFi AP.

I still don't know how to backup the original FW from ESPHome, it simply instantly installed the default code on to it. Then edited it with the code provided here, re-flashed, and happy.

helgek commented 3 months ago

To back up: esptool.py --baud 115200 --port /dev/cu.usbserial-110 read_flash 0x00000 0x400000 fwbackup_xyz.bin

To compile: esptool.py compile airpurifier.yaml

To flash: esptool.py --baud 115200 --port /dev/cu.usbserial-110 write_flash --flash_size detect 0x00000 firmware-factory.bin

With automatic port detection this might also work instead: esphome run airpurifier.yaml

smogger commented 2 months ago

In some cases, one of my purifier lose Wifi connection.

I added the following line to the code, but it seem doesnt really reset the ESP upon disconnect.

"wifi: ssid: !secret wifi_ssid password: !secret wifi_password reboot_timeout: 15min "

Am I missing something??