[Part 2] Smart Home Project: Flashing and configuring Sonoff Devices with Tasmota

[Part 2] Smart Home Project: Flashing and configuring Sonoff Devices with Tasmota

Hey, this is part 2 of my smart home project! This article will be a lot more interesting than the previous! We will see what is within the Sonoff Basic Switch and Touch as well as flashing and configuring them with Tasmota.

1. What are the Basic Switch and Touch modules?

The Basic Switch module is just a simple relay with build-in WiFi connectivity. It gives you an option to switch it On or Off remotely. The drawback if you're using it to control lights in an existing home wiring - you should always keep the current light switch in On position to provide the module with constant electricity.

The Touch module is a normal but fancy glass light switch with build-in WiFi connectivity. Like the Basic Switch, it gives you an option to turn it On and Off remotely as well as using it as a normal switch by touching the glass surface. The drawback here is if you're living in a country where the standart lights wiring is to have only the Line (+) wire in the switch enclosure, you have to supply a ground wire from somewhere else.

2. Why do you need to flash them with Tasmota?

The Sonoff's software is not open-source and doesn't provide any public API to enable you to communicate with the modules through your software. Tasmota is an open-source solution that gives you a full control over the modules via MQTT, REST API and Serial.

3. How to flash the Sonoff's modules with Tasmota?

First, you have to buy a special USB-TTL converter module. I bought this one from eBay and it works perfectly - CP2102 USB 2.0 to TTL UART Module 6Pin Serial Converter

CP2102 USB 2.0 to TTL UART Module 6Pin Serial Converter

With this tiny device you will be able to flash any Sonoff module easily.

Lets begin with the interesting part of this exercise! 😜

Now you have to wire the Sonoff Basic Switch with the USB-TTL converter. You can solder four cables if you want.

After you succesfully wired both devices lets move on with the flashing process:

  1. Download the esptool:
    1.1. Using brew on Mac: brew install esptool
    1.2. Using pip on Mac or Linux: pip install esptool
  2. Download the latest Tasmota sonoff.bin release
  3. Wire the TTL UART's module with the Sonoff's module
  4. Push the Sonoff Basic Switch button and keep it pushed until you fully inserted the TTL UART's module into the computer's USB port
  5. Flash with the following command:
    esptool.py --port /dev/[USB_to_UART port] write_flash -fs 1MB dout 0x0 [PATH_TO_SONOFF.bin] *

* Beaware that I don't take any responsibility and I'm not liable for any damage if something wrong happens during the flashing process. You're doing this on your risk!

If everthing went okay, the light will flash once.

Now the Sonoff Basic Switch module will create an open network with SSID like ITEAD-*****.

Connect to the network from your computer or mobile device. Once you are connected, a new page will open in the browser where you will need to enter your home network's SSID and password:

After you click on the Save button, the module will restart and try to connect to your home's WiFi network.

Go to your router's admin panel (for most routers is located at: or and find the IP of the module.

Then open your browser and go to: http://[DEVICE_IP].

And... that is all! Now you have a Tasmota Sonoff smart device! You can toggle it from this address or communicate with it through it's REST API, MQTT or Serial channels.

Super cool, eh! ðŸĪŠ

I hope that this article is easily comprehensible! If you have any questions or missunderstandings - don't hesitate to write in the comments box below. 👇

Atanas Dimitrov

Atanas Dimitrov

Plovdiv, Bulgaria