Flash SonOTA to ITEAD devices over WiFi + mqtt control: for dummies!

Hey guys,
Complete dummy here, i lurked around the forums, github and reddit trying to figure stuff out, i finally did
So im sharing for the next dummy who might be looking into it :slight_smile:

So here is how I did it on win7 while being completely ignorant:

  1. Get a PC with WiFi and a sonoff on version 1.5.0 (I believe 1.6.0 is not flashable at the moment)

  2. Disable any firewalls you have, including windows firewall.

  3. Make sure you do not have static ip settings set on your wireless network connection.
    • To do that, Hit the Win key. Type network connections. Hit enter.
    • Double click on your WiFi Network connection, click Properties, then double click on “Internet Protocol Version 4” line and make sure that both the bullets are set to the first option, to obtain IP and DNS automatically.

  4. Download and install the latest version from here: https://www.python.org/downloads/
    • Was python 3.6.3 in my case.
    • Make sure you tick the “Add Python x.x to PATH” option on the first screen
    • To make sure that it’s ok, hit the windows key, type in “advanced system settings” and hit enter. It should be already in the advanced tab, in that tab, click the “environment variables” button. There should be an entry there with the variable PATH and the value equal to the location of the python installation on your hard drive.

  5. Download and install “Visual C++ 2015 Build Tools” from here: http://landinghub.visualstudio.com/visual-cpp-build-tools

  6. Visit https://github.com/mirko/SonOTA , click on the green “download or clone” button and download the zip . (direct link: https://github.com/mirko/SonOTA/archive/master.zip)

  7. Extract the zip you got from github to a directory. Remember that dir, you will have to type it soon.

  8. Hit the Win key. Type cmd. Hit enter

  9. Now, using cd.. to go one dir up, cd/ to go back to the main dir and cd xxxx to enter a folder named xxxx, navigate to the directory where you unpacked the zip file form github.

  10. Once there, we follow the guide from github and type pip3 install --user -r requirements.txt. A process should run to update your files.
    If you get a red code message (like i did) you might be missing the visual studio tools from the 5th step above.

  11. Once this is done, press the button on your sonoff until the led starts flashing rapidly, then back to the cmd window, type sonota.py or python sonota.py and the program started. Selected 0 for my wlan connection and let it run for a couple of minutes.

  12. Once this was done (there are instructions every now and then inside the program itself), a new WiFi network named FinalStage will appear in your computers WiFi networks. Hit the wifi icon in your tray area and hit refresh on the upper right corner of the window. As soon as it appears, you are good to connect to it. Once connected, the program will run some more commands and come to an end.

  13. The FinalStage wifi should disappear and a new one should become visible (be sure to hit refresh again) named sonoff-XXXX depending on your device.
    Connect to that network.

  14. Hit the Win key. Type cmd. Hit enter. Type ipconfig in the cmd window. Hit enter.
    Depending on your computer and connections you may see various things there.
    Look for the “Wireless LAN adapter” section.
    Note the Default Gateway ip address.
    Should be

  15. Open a browser and type this address on your address bar.
    You should land on a page that reads Sonoff Basic Module and here is where you set up the details for the device to connect to your homes wireless network.

  16. Once you fill in your WiFi details, the sonoff should restart, the sonoff-XXXX access point will disappear and it should connect to your pre-set wifi network.
    • I had some issue here, and the sonoff would keep restarting without connecting to my home network several times. I would see the sonoff-XXXX network disappear during reboot and reappearing after. At some point it worked, I have no idea how, I just stopped seing the AP.

  17. No once it’s connected to your home network it will automatically get IP address through DHCP.
    There are several ways to find out which address it got.
    One is to use an IP scanner to see changes on the devices on your network, another is to just know which one it will be through the settings of your wifi router, or whatever you use as a DHCP server.
    Once you find that address, key it in the browsers address bar and navigate there.
    Make sure your computer is connected back to your home network.
    Also, you will probably need to set a static ip to your itead device. This cannot be done through the UI yet, so head on to the console and type IPAddress1 x.x.x.x (entering your desired ip instead of the x.x.x.x - for more information on that check the 3rd link below about commands)

  18. You will see some buttons and options there. Now you can get to work to connect it to whatever Home Automation solution you use.
    I for once, need to go study what MQTT is and how it works so I can connect it to my Hass.io thingy :slight_smile:

  19. Further information from this point onwards can be found here:
    https://github.com/arendst/Sonoff-Tasmota/wiki/Commands which can be used in the console interface of your device found in this address: http://itead.ip.address/cs?

Hope I helped out some folks here who are complete dummies like me :slight_smile:

Thanks to u/digi-ghost for providing me with some starter steps, to this german page thread http://forum.creationx.de/forum/index.php?thread/116-neues-flash-vervahren-ohne-hardware-nur-über-wlan/ and to google translate.
And ofcourse to arendst and mirko for making all these possible :slight_smile:

Edit: Part 2, how to connecto to HA with MQTT

So that took me some time too but here it is, for dummies:

  1. Navigate to your new Sonoff IP address

  2. Click “configuration”, then “Configure Other”, Make sure “MQTT enable” is ticked.

  3. Click “configuration”, then “Configure MQTT”

  4. Fill in the following:
    a. Host: your local HA ip address
    b. Port: leave it 1883, as this is the default for HA’s embedded broker that we will set up in step 4
    c. Client: Something unique for your sonoff device – it must not match HA’s client name (in case you are using a configurable broker)
    d. User: homeassistant
    e. Password: your home assistant password
    f. Topic: leave as it is if you are only using one device, or change it if you plan on using more, I put in sonoff1
    g. Full topic: leave as is

  5. Now on the HA side, open your configuration.yaml and add this in its own line mqtt:, this enables HA’s embedded broker

  6. Depending on where your switches are (within configuration.yaml or in a separate file), add a new switch like this:

      - platform: mqtt
        name: "sonoff test 1"
        state_topic: "stat/sonoff1/POWER" # sonoff1 or what you set in the topic field in Sonoff configuration
        command_topic: "cmnd/sonoff1/power" # sonoff1 or what you set in the topic field in Sonoff configuration
        payload_on: "ON"
        payload_off: "OFF"

Now reboot your HA and you should have a new switch that controls the little devil.

  1. There seems to be a simpler solution, by enabling the hue emulation in the sonoff (configuration -> configure others) and it gets detected by HA automatically but, it doesnt seem to work for me.

For further configuration go ask the big guys, that’s all I figured out so far.
Hope this becomes handy for someone :slight_smile:
& I hope i havent done any critical mistakes that would misslead someone

Comments, corrections and improvements are more than welcome!


I followed simlair steps today all was working great then after about 2 hours lost all connection to the sonoff. Have powered it off/on still nothing. Am getting no response to the onboard button. Tried to see if it was connected to the wifi nothing showing on my router and its not broadcasting as a AP so appears dead. I suspect the only way to maybe fix now is via FTDI

Does the led light up at all?

That’d be ironic, at least flashing it the old fashioned way is a lot quicker :slight_smile:

Yes the led does flash but that’s all it does

Since you are not seeing any AP to connect to, i cant think of anything.
Maybe they can help you out here

think I found the issue, I have brought the FTDI adapter and initially, that failed to flash as well, but by changing the board to ESP8255 it worked so maybe the SonataOTA is fixed to the ESP8266 and then doesn’t boot back up again afterwards

I managed to flash a v.1.6.0 too using the adapter and pins. following the official guide, just had to switch RX/TX.

Anyone tried this with a SonOff POW with firmware 2.04?

Got a couple of pow’s stashed somewhere but I haven’t gotten to tweak them yet. I’ll let you know if will :slight_smile:
edit: typos