Using Sonoff Tasmota software

Adding Tasmota experience to Sonoff devices.

Encouraged by the latest ESP hacks and your comments, I decided to take a look at the Sonoff Tasmota software too. I love to learn by trial and error and writing a custom code for ESP based devices is a perfect way of experimenting and learning new skills, but sometimes you just want to add an extra functionality to the device without writing a new set of drivers each time. Sonoff Tasmota software is just that.

Sonoff Tasmota software

The Sonoff Tasmota software can be flashed on most of the Sonoff devices. I’m going to use Sonoff Basic, which is, well… pretty basic. Out of the box, this $5 switch does 1 thing: turns the relay on and off. It has an Android/AppleOS support and integration with Alexa and Google Home.

Support NotEnoughTech

This pretty basic gadget has an ESP8266 brain. This means, there is so much more potential inside that case. Before we get to the software part, take a look at the Sonoff Hacking guide where I show you how to backup and flash custom software.

The main advantages of the Sonoff Tasmota software include:

  • full local network compatibility
  • support for MQTT protocol
  • support for HTTP request
  • the utilisation of extra GPIO pins (GPIO14 on Sonoff basic)
  • support for most common sensors
  • OTA updates
  • Belkin WeMo and Phillips Hue emulation
  • Timers
  • Domoticz integration

As you can see, the list is impressive for a free software that you can simply download of the internet. There is something missing on this list. There is no native integration for Alexa or Google Home. While this is a bummer (I’m pretty sure a commercial release of Sonoff Tasmota would include the licence for that), a bit of IFTTT tinkering will enable both.

Flashing Sonoff Tasmota

For the most part, follow the Sonoff Basic flash guide (remember to make the backup of the original software), then download the Sonoff Tasmota image file from this website (sonoff.bin is the default firmware in English). Put the file inside the esptool folder, reboot the Sonoff device holding down the button for 2-3 sec and flash the new software using this command:

python --port COM11 write_flash -fs 1MB -fm dout 0x0 sonoff.bin

This should take less than a minute. Once the firmware is flashed, disconnect the serial programmer and power the Sonoff Basic using the power cable (note that you won’t be able to get to the configuration page with the serial (RX/TX) connected.

Sonoff Tasmota Setup and configuration

To put the Sonoff Basic into the configuration mode you have to press the button four times (quickly, until the light is flashing). There is more than one function of the button, here is the breakdown:

Button press x times Function LED behaviour
1 toggle the relay ON/OFF blinks twice
2 toggle the 2nd relay ON/OFF (if available) blinks twice
3 Smart WiFi config using the Android app LED blinks
4 Set Sonoff in AP mode LED blinks
5 WPS setup LED blinks
6 restarts the Sonoff
7 OTA download of firmware steady lit up
40sec Factory reset
ESP8266 SmartConfig
Price: Free

Pick your way of adding the WiFi credentials and the Sonoff config page will be available under:      //fill in the xxx with your Sonoff's IP

From there, things are pretty straightforward. Pick a menu, add your details, rinse and repeat until you are done.

Every menu option is clear and self-explanatory, you should not have any problems with the configuration. It’s worth noting your MQTT configuration, so you could set up the controls in NodeRED.

MQTT control

The full list of commands is available here. In a nutshell, to control the Sonoff device via MQTT protocol you have to configure the MQTT topics correctly.

%topic%  (sonoff)
sonoff/cmnd/power1   //controlling relay1 

Full topic
sonoff/stat/RESULT   //receiving status message

The query submitted back via MQTT looks like this:


HTTP control

It is also possible (despite the MQTT being the default control protocol to control the Sonoff device with the HTTP requests. The requests will contain the username and password if you locked the Sonoff Tasmota web interface with it.

Here is an example: = Sonoff's IP
Power = command type
TOGGLE = value
USERNAME,PASSWORD = use your web access credentials = Sonoff's IP
Power = command type
TOGGLE = value

The response given will contain a JSON object with the current device state. If you want to learn more about JSON I have the basic tutorial for you.

Sonoff Tasmota  – Google Home and Alexa integration

While the smart speaker functionality isn’t there, you can simply add the Alexa and the Google Home integration to your NodeRED setup. You can use IFTTT to send a web request, which in turn will transform your spoken command in a webhook.

Google Home, Sonoff Tasmota & IFTTT

Create an IFTTT trigger with a word phrase (don’t use Sonoff name, Google thinks you are saying “song off“):

Turn the switch $

And link this to a webhook:


with a JSON type message:


Then use the HTTP POST (in) node in your NodeRED setup. The message containing ON/OFF will be stored under msg.payload.sonoff and you can use a function node to convert this for the full URL to control the Sonoff device:

var x = msg.payload.sonoff;
msg.url = "https://sonoff_IP/cm?cmnd=Power%20"+ x;
return msg;

Alexa, Sonoff Tasmota and NodeRED alexa-home node.

The alexa-home node is great, as you can add the devices very quickly. Log in and create a new device (ON/OFF) and drop the node into the NodeRED setup. The default message from the alexa-home is true/false – so I’m going to use switch node to monitor these replies and issue a correct URL for the HTTP POST request.


Sonoff Tasmota firmware is a very quick and painless way of controlling Sonoff devices. It takes moments to set up and support for the MQTT and HTTP makes it compatible with most of the automation hubs. If you can live with the 3rd party smart speaker support you will be very happy with the transition to Tasmota based firmware.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.