Summary

I recently needed to flash some Sonoff S31 power switches, and realized I forgot to write down what I did and how to do it. Thankfully the process (thanks to ESPHome) is exceptionally easy. So this is a quick write up to explain the disassembly and flashing process.

Disassembly

First pull the grey power button plate off the S31 switch, this can be done with a small flathead screwdriver.
s31-assembled

s31-plate-removed

After the power button plate has been removed there are two sliders that can be removed:
s31-sliders

Note:
The screws on this device are exceptionally cheap, be careful when removing them. You can see I have already started to strip them.

Once the sliders are removed, three screws will be exposed, remove them:
s31-screws

The PCB can now be removed from the shell:
s31-pcb
Take note of the contact pads (top to bottom):

  • VCC
  • RX
  • TX
  • D - TX
  • D - RX
  • GND

Getting a console

usb-to-tty
I have attached (top to bottom):

  • Blue: RXD
  • Green: TXD
  • Black: GND
  • Red: VCC
Warning:
Ensure voltage on your USB to TTY device is set to 3.3v

Now attach:

  • Black: GND
  • Blue: TX
  • Green: RX
  • Red: VCC

s31-jumpers-attached

Before plugging the USB into a computer, press and hold the power button on the S31, while holding the power button plug the USB in, continue holding the power button for ~5 seconds.
s31-flashing

The device is now read to be flashed.

Flashing

Flashing is as simple as:
sudo esphome run ./s31.yaml