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
When you burn the new firmware, you will loose the original, from manufacturer. Do you know if someone has the original firmware ?
Hi Miguel,
I have a quick note that states that in this guide. They don’t provided the original firmware and I couldn’t find anyone that was able to re-flash with the original firmware…
Thanks!
But You can still make a backup copy of internal firmware before reflashing. Just use esptool.
That should work, but the manufacturer doesn’t offer the original firmware to re-flash.
That’s what I meant.. Thanks!
I just ran tasmoto tasmotiser and it has the option to save the original binary to your pc for use later if you choose.
hi, i have flashed nodeMcu firmware and init.lua on sonoff device. While it is connected via FTDI programmer it works, but when i plug it in electric socket it does not work at all. Do you know where could be the problem ?
I’m not sure, but it should work…
Hi,
Will any 3.3 V FTDI module, like the one at the next link, work?
goo.gl/j9h7tk
Thanks in advance for your answer,
Gijs
Hi.
Yes. That FTDI module works, but you might have to install some drivers in your computer.
Note that there’s a jumper wire to set the operating voltage to 3.3V. You need to place the jumper wire in 3.3V rails, otherwise you may fry your ESP.
hi,
i just uploaded the led blink program but it does not work. it shows nothing on the serial monitor too. i also tried web server for the relay. same thing: the upload goes well, but after that nothing.
serial monitor nothing, mains conected nothing.
the module is sonoff basic with 5 pins on the board
any help apreciated !
Which LED blink code are you talking about?
Did you select the DOUT option during the upload in your Arduino IDE?
Hi, thanks for great work Rui. Do you have a version for Dual R2?
Hi.
We don’t have any tutorial about that.
Regards,
Sara 🙂
I’ve changed my router and now my sonoff switch won’t reprogram to my new router?
Is there a way to reset the switch to factory defaults ?
Hi Keith.
Basically, after you flash the SONOFF with a custom firmware, (as described in the blog post) I don’t think you can reverse those changes.
Unfortunately, SONOFF doesn’t provide the original firmware.
If you need to change the SSID and password from one of our examples, you just need to modify the sketch and flash the SONOFF with that sketch.
Regards,
Sara
Has anyone used a Sonoff Touch US Power Ver 1.0?
It uses a iTead PSF-A processor which is a ESP8285 processor.
https://www.itead.cc/wiki/PSF-A85
Not sure what Arduino version I might use?
Ralph