Posted on 5 Comments

#30: Reflash ANY Sonoff, even if you don’t know the pinout

Sonoff is very popular for DIY home automation, but you can make it even better by loading new firmware onto it. Learn how to connect a USB-to-Serial converter to ANY model of Sonoff, even ones that haven’t been released yet!

This episode isn’t just a series of steps to follow: it’s a tutorial on how to reverse engineer the connections to the ESP8266 / ESP8285 microcontroller in an unknown circuit, and put it into bootloader mode ready to receive new software.

ESP8266 Strapping Pins

The strapping pins set the boot mode of the microcontroller. Typical ESP8266 circuits have an arrangement similar to this:

In the Sonoff, GPIO15 is pulled low to 0V, and GPIO2 and GPIO0 are pulled high to 3.3V.

If GPIO0 is held low (0V) during startup, the ESP8266 will go into bootloader mode and be ready to receive a new program uploaded via the serial connection on the TX and RX pins.

You can often find the appropriate connections on the PCB by tracing out the pins on the microcontroller. The relevant pins on the ESP8266 and ESP8285 can be found in these locations:

With only a couple of exceptions, most Sonoff models include a 4-pin header on the PCB that exposes GND, 3.3V, TX, and RX.

You can use a USB-to-Serial converter to connect this header to your computer by USB, so that you can upload a new program. You can make an adapter cable using these connections:

It’s a simple cable to hand-wire, but that can be annoying so to save time I designed a simple adapter that you can use between a USB-to-Serial adapter that uses the common “FTDI” pinout and the Sonoff:

The adapter makes it very easy to connect to most Sonoff models. Make sure you use a USB-to-Serial adapter that runs at 3.3V because it’s not safe to connect 5V. Doing so could damage the ESP8266 microcontroller.

Sonoff Basic Pinout

More detail to be added here soon.

Sonoff POW / TH10 / TH16 Connections

More detail to be added here soon.

Sonoff 4CH Pro Connections

More detail to be added here soon.

Sonoff Slampher Connections

More detail to be added here soon.

Sonoff B1 Connections

More detail to be added here soon.

Sonoff Touch Connections

More detail to be added here soon.

5 thoughts on “#30: Reflash ANY Sonoff, even if you don’t know the pinout

  1. Nice interesting article as always. Why don’t put a ground pin header on the adaptor for the gpio0 wire ?

  2. Any chance you can review the sonoff basicr3 and it’s GPIO pins?

    1. Yes, I’d like to do that. I don’t have an R3 so I need to order one

  3. I have subscribed your youtube and I really wondered how you are explaining and giving the details
    Since my enthusiasm and curiosity si the only driving force to appreciate you I am not technically qualified and aged 65 and still updating knowledge is because of people like you.
    Thank you and all the best wishes from INDIA, Kerala

  4. Hi. I just found your site and although a great deal of the more
    technical speech is lost on me I gained enough knowledge to be
    dangerous. I have just successfully flashed my sonoff basic using
    NodeMcu and tasmota.bin v8.5.0 by Theo Arends . https://github.com/nodemcu/nodemcu-flasher . My main purpose of flashing was to be able to control my switch through a smartthings hub. The flashing worked but the device handlers and smartapps still don’t discover my switch. My question therefore is there a known flashing tool or version of the bin file that is known to work well with smartthings? I followed these instructions below. Thanks so much https://community.smartthings.com/t/release-sonoff-sonoff-th-s20-dual-4ch-pow-touch-device-handler-smartapp-5-10-smart-switches/45957

Leave a Reply

Your email address will not be published. Required fields are marked *