Hi,
I’m trying to flash ESPHome on Sonoff M5 switch. According to web tutorials, it should be trivial. I’m stuck with ESPHome being unable to connect to the device.
Connected rt-tx, tx-rx, gnd, v3.3, and when turining on the device I keep the button pushed to enter programming mode.
From HA/ESPhome when I add new device, click connect, the interface asks for COM port (using chrome to do serial programming), but connection doesn’t succeed.
In ESPHome log there’s only a very long sequence like this, no errors:
2024-06-23 19:08:16,725 INFO 304 GET /devices (0.0.0.0) 1.64ms
2024-06-23 19:08:22,713 INFO 304 GET /devices (0.0.0.0) 1.64ms
2024-06-23 19:08:28,703 INFO 304 GET /devices (0.0.0.0) 1.41ms
2024-06-23 19:08:30,143 INFO 200 GET /devices (0.0.0.0) 1.53ms
2024-06-23 19:08:34,707 INFO 304 GET /devices (0.0.0.0) 1.65ms
2024-06-23 19:08:39,717 INFO 304 GET /devices (0.0.0.0) 1.35ms
2024-06-23 19:08:45,703 INFO 304 GET /devices (0.0.0.0) 1.61ms
2024-06-23 19:08:51,714 INFO 304 GET /devices (0.0.0.0) 1.50ms
2024-06-23 19:08:57,702 INFO 304 GET /devices (0.0.0.0) 1.46ms
Double tested that the device works normally, connected to 230V and eWeLink from smartphone, it works ok.
I connected the TX to the RX of the USB2TTL, and it seems to be working properly. The problem might be with the M5 board.
How can I test if the TX and RX of the Sonoff M5 are working correctly?
I don’t know about the Sonoff M5, but the Sonoff labeling of +3,R,T,G has been consistent with all of the Sonoff devices I have here. And I have no experience with your particular FTDI, but I have seen one that mis-labeled the T & R. If nothing else seems to work, try connecting T-T and R-R. It can’t hurt anything.
Not one of the new white Matter compatible M5’s is it, seems to reports on the web that these are locked firmware.
I have one of the white ones and Matter works quite well, didn’t try flashing it due to reports of not being possible. Just added mine straight to HA didn’t need to use EWeLink app.
Hey, I didn’t expect I would come back here, but I just found the solution, after trying to flash another sonoff device, having similar issues, I decided to try something looking really dangerous… I tried to flash the device with 230v ac power connected, and guess what - it worked!
I’m still using the same FTDI232, output set to 3.3v, using following procedure:
Connect the FTDI cables (VCC, RX, TX, GND) but don’t connect it to the PC USB yet
With ac power turned off, connect the 230v Lin and N cables
Press and hold the button (my switch is 1-gang, so the gpio00 is connected to the button)
Turn on AC power. You should see the blue led turned off, meaning the device is not attempting to connect to Wifi, but rather waits for the programming.
After a moment, release the button.
Plug in the USB cable into the PC
In Home Assistant ESPHome tab, create new device and connect. Of course you need to have the usb/serial driver installed. I’m using this one: https://ftdichip.com/drivers/
It should connect, then takes a moment creating config, programming and the device goes online with no functionality.
Power off the device, disconnect the FTDI, assemble and seal the cover.
Power on, the device should become online in a moment in ESPHome.
Update yaml config and install it using wireless update. Done.
BTW, if you’re stuck with the yaml config, I’m copying mine below.
The one that google finds here is invalid. Here you’ll find the ESPHome reference, but they only provide ready config for 2- and 3-gang, while the 1-gang is slightly different.
Here’s mine:
It’s dangerous because you are exposing line voltage to possible finger contact. What your experience tells me is that the Vcc (3V) pin is not powering the ESP correctly. When you connect Vcc (3V) and Ground only, does the LED indicate that the device is trying to connect to WiFi? (It should).
I took required safety steps to protect myself from touching the 230v line. I have a cable with additional power switch, that cuts off the power for the time of assembling the device for programming, and then put it on rubber pad before turning on the power and using isolated tool to press the button. My biggest worry was that the ac power might have propagated through the programmer into the USB port of my PC…
With 3.3v VCC only, the device doesn’t show any signs of live, but even with the 230v line attached, when powered on with the button pressed, the device goes into the programming mode and no leds flash.