Trouble flashing a Sonoff S31

I picked up an S31 Sonoff, intending to flash it with Tasmota. I followed the directions here: http://tinkerman.cat/sonoff-s31-now-serious/#lightbox-gallery-iVhoDOpK/17/ for disassembling and wiring it. I’m using a Sparkfun FTDI Beefy 3 USB to UART programmer, with Tx on the programmer connected to Rx on the Sonoff and vice versa (I tried swapping, just in case, but it didn’t fix anything). My understanding is that the Beefy should provide plenty of current. The Beefy itself is run off a powered USB hub.

As far as I can tell, got the wiring correct - I’m seeing continuity from the Beefy all the way to the other side of the board for Gnd, and from Beefy to the little chip that looks like a power regulator for the 3V3 line, and a blue LED lights up on the Sonoff. It’s harder for me to test continuity of the Rx/Tx lines, as I don’t know where those lines are supposed to go past the pad, having a hard time tracing them to some place I can probe.

The Sonoff was (foolishly) updated to the latest firmware, which killed any chance of flashing it over the air, but, afaik, shouldn’t impact flashing over serial.

Following the Tasmota instructions here: https://github.com/arendst/Sonoff-Tasmota/wiki/Esptool I ran the command to backup the current firmware (more as a test than anything), as follows:

py esptool.py --port COM4 read_flash 0x00000 0x100000 image1M.bin

(on my windows machine I have to use py or python to execute Python scripts, after installing and removing PyCharm I could never get it to just run them again without it)

COM4 is the port that Windows assigns the Beefy.

I get this result, every time:

esptool.py v2.6
Serial port COM4
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Invalid head of packet (0x00)

Anyone have any ideas? Other things to try to diagnose the problem?

Thanks.

I don’t know if I can help much as I’ve never seen a Sonoff S31, but I have flashed several Sonoff Basic modules and a few Sonoff switches.

The error means that your flashing firmware is not able to establish a connection to your ESP. In my case, I have gotten this error when I have the serial port open in another window. You may also get the error if your Tx/Rx are reversed or if GPIO0 is not grounded when powering up the ESP through the FTDI.

It could also be the wrong port. Open the Device Manager, then expand the COM ports. Note the existing COM ports, then plug the FTDI adapter into the USB port. The new port is the one assigned to the FTDI adapter.

I have heard of people having difficulty flashing ESP because they weren’t using a legitimate FTDI adapter, but I would trust the Sparkfun FTDI adapter board to be using legitimate FTDI parts.

I found esptool difficult to use and I now use FlashESP8266.exe from https://github.com/BattloXX/ESPEasyFlasher
All you need is the exe and the bin file from Tasmota. No Python required.

1 Like

I’m pretty sure I’m good on the other aspects you mentioned. I’ll try the other tool when I get back home, see if that’s where the issue lies.

this is what i used to flash my s31’s
esptool.exe -vv -cb 115200 -cp COM7 -ca 0x00000 -bz 1M -bm dout -cf sonoff.bin
have done 6 all work great.

1 Like

Did you ever get this to work? I have some Sonoff S26s and have a similar problem. I am using the Freetronics USB to Serial here. I am on a Mac so my port is a little different. I have used a Feather Huzzah and successfully used the esptool to read out but the sonoff doesn’t seem to work.

I did, but I can’t recall what the issue was… :frowning:

It did work with the ESPEasy flasher, but I know I got esptool to work as well. Not sure I ever got the read command to work, but I definitely was able to both erase and write the S31.

I think it was just bad connections. I was trying to set up a jig for flashing it without soldering on wires, and it didn’t work. I’ve since set up a different jig, which did.

I recently started using the ESPhome yaml project and converted my s31’s over to that.
it was super easy and i like the integration with HA instead of having to create CLI sensors.
so just an FYI incase you were interested.

Is ESPHome Yaml the same thing as ESPHome? I’ve got a single device using ESPHome (a Bruh DIY multisensor) and it works great.

Yeah he recently renamed it to just esphome.
but i really like the project. it’s working well for my s31’s and i’m about to build a network of sensors with esp32’s and am planning to use the esphome for it.

1 Like