There are quite a lot of hacks available for the Sonoff. This range from this simple "add a serial header" to actually adding more GPIOs by connecting to the bare chip directly. I'll let that as an exercise to the reader.

Warning : You won't be able to revert to default Sonoff firmware.

If you'd like to support me in writing other instructables, please buy hardware from the Amazon sponsored links.

Step 1: Adding a Serial Header to the Sonoff

Depending on your skills, this might be the easiest to do. The Sonoff products are hackers friendly.

After having tested this, I've decided to glue together the connectors pins on the cable. As there is a gap on FTDI side between ground and TX/RX/VCC, I've added a dupont plastic pin without any cable as a filler. I also marked the GND cable on each side to prevent any mistake.

WARNING 1 : The port on the Sonoff is 3.3V, make sure you use proper FTDI adapter and/or set its voltage accordingly.

Make sure you can compile sources. It is particularly important to make sure you use the proper target controller, for this Sonoff device you'll need to select "Espressif Generic ESP8266 ESP-01 1M" (esp01_1m in platformio.ini).

Once compilation goes fine, we can proceed to actual flashing.

Flash

The Sonoff won't listen to you as-is, unplug it, press its button and release it after you plugged it back. It is required to have button pressed BEFORE powering it to enter "flash mode". This actually drives GPIO 0 down by connecting it to GND.

Now that Sonoff waits for flashing, send it the firmware.

It's alive!

Congratulations! You are now the proud owner of a hacked Sonoff device with custom firmware!