Flash Tasmota Firmware to a Sonoff Smart Socket

As a vintage IOT enthusiast I used to flash my own ESPs with code I patched together in the Arduino IDE. My sketch would include WiFi and MQTT credentials along with a few "if then" instructions. I'd attach the ESP to a relay and configure things in Node Red running on a Raspi.

This was well and good at the dawn of IOT, but as commercial companies entered the field, things got more complicated.

Attempting to draw customers into their ecosystems, companies developed apps and protocols to work with only their devices. The result was that if you bought devices from several companies, not only would you need a specific app, but one company's devices wouldn't talk to another. Many of us ended up with entire panels of IOT apps just to control a few switches and lights around the house. To make matters worse, we'd end up using nefarious Chinese web servers that nobody really trusted.

The answer was to use Home Assistant or Node Red, but in each case, you needed an interface to make everything communicate.

Sonoff

Sonoff was among the first to produce useful commerical IOT devices. Using an ESP8266, their smarts were cheap, reasonable quality, and easily available. Eventually they developed Ewelink, their cloud system to take control.

As they were among the first, and because the ESPs had started in the hobbyist realm, developers were quick to create Open Source firmware to enhance control of Sonoff devices. Hence Tasmota was born.

Tasmota

Tasmota, originally developed by Dutch Developer, Theo Arends, in January 2016, was designed to replace the factory firmware on Sonoff's ESP8266 devices. It was local, would allow simple menu-based configuration, and remove dependency on Sonoff's cloud-based services.

By logging into the web page broadcast by the ESP, the user can set Wifi credentials, MQTT, sensor pins, and a host of other parameters. It runs on anything from the basic ESP8266 01 to the ESP32. It is OTA (Over The Air) and after nearly a decade of development, it is extremely stable and reliable.

Many Sonoff devices can happily run Tasmota firmware, and when they do, control is much more extensive, absent reliance on external Chinese servers.

Flashing Tasmota to Sonoff Smart Plug

These instructions relate to the Sonoff S26R2TPH Smart Plug.

Opening it up, look around the ESP chip to find the four pins V, RX, TX, and GND.

On my particular board, I don't have the ESP8266, but the ESP8285 - a very similar chip but with 2MB of SPI flash built in. Tasmota can be flashed to the 8285 in exactly the same way as the 8266.

Solder wires onto the four pads. I suggest Dupont wires as the other end will need to go to your FTDI USB To TTL Serial Adapter.

The ESP is exclusively 3.3v so don't use a 5v dongle. (I've used 5v on ESP Development Boards, but this is not a Dev Board and won't be 5v-tolerant.)

Make sure to connect the TX pad to the RX pin and the RX pad to the TX pin. Of course, V and GND go to the 3.3v pin and GND.

Web-based Tasmota Binaries and Installer

Fortunately, to flash the firmware, we no longer need to use Arduino IDE. It can be done directly from a web page. Personally, I use a Raspberry Pi for flashing because I find linux reliable, and the RasPi Chromium browser is devoid of bloatware and complications.

From this link, download the binaries that are best suited to your needs. As I am using a simple on-off switch, tasmota-lite.bin is sufficient and ensures that I won't run out of memory as I'm flashing.

Use this link to access the Tasmota flashing tool.

First, upload your factory.bin, then click Connect. Select your USB port.

GPIO 0 to GND

Instructions say that GPIO 0 needs to be grounded, so I spent half an hour trying to find a microscopic breakout pad for GPIO 0. After several failures, I realized that my smart switch had a button - could it be this simple?

So, I powered up the ESP with the button pressed, then released it. To my amazement, it worked.

Configuring WiFi

At the end of the flashing process one of two things will happen. Either the flasher will ask if you want to set up WiFi, or it won't. If it doesn't, restart your ESP and search for a Tasmota SSID on your WiFi. It will automatically open a form for you to input your WiFi credentials. Once this is done, you should be able to access your Tasmota smart plug at its IP address on your local network.