In this post, you’re going to learn how to flash custom firmware to the Sonoff device. I recommend that you read my previous post to get familiar with the Sonoff.
If you don’t have a Sonoff yet, you can get one for approximately $5 – visit Maker Advisor to find the best price.
First, watch the step by step video tutorial below
The code mentioned in the video can be found here: “Reprogram Sonoff Smart Switch with Web Server“.
Safety warning
Make sure you disconnect your Sonoff from mains voltage. Then, open the box enclosure.

Sonoff pinout
The Sonoff is meant to be hacked, and you can see clearly that these connections were left out, so that you can solder some pins and upload a custom firmware.
That’s the pinout.

I’ve soldered 4 header pins, so that I can easily connect and disconnect wire cables to my Sonoff device.

Preparing your 3.3V FTDI module
You need an FTDI module to upload a new firmware to your Sonoff. Use the schematics provided as a reference.

Warning: uploading a custom firmware is irreversible and you’ll no longer be able to use the app eWeLink.
I’ve added a toggle switch in the power line, so that I can easily turn the Sonoff on and off to flash a new firmware without having to unplug the FTDI module.
I used hot glue to glue the ends of the wires together. This prevents you to make wrong connections between the FTDI and the Sonoff in the future.

Boot your Sonoff in Flashing Mode
To flash a new firmware to your Sonoff, you have to boot your Sonoff in flashing mode. Follow this 4 step process:
1) Connect your 3.3V FTDI programmer to your computer
2) Hold down the Sonoff button

3) Toggle the switch to apply power to the Sonoff circuit

4) Then, you can release the Sonoff button
Now, your Sonoff should be in flashing mode and you can upload a new firmware.
Sonoff tutorials list:
Wrapping up
That’s it for now, I hope you had fun learning about the Sonoff device. Make sure you subscribe to my blog, because I’ll be posting more tutorials about the Sonoff.
Do you have any questions? Leave a comment down below!
Thanks for reading,
Rui
Our new book is a beginner-friendly collection of electronics projects, perfectly suited for hobbyists, parents, kids, parents, and educators looking to level up their hardware skills - GET THE BOOK »
Recommended Resources
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.
Learn how to build a automation system using open-source hardware and software from scratch.
Build 25 cool Arduino projects with our couse even with no prior experience!