How to flash Tasmota to your Sonoff

In a year’s time, we will be ushering in the 2020s, I’m sure you have heard all about making our homes smarter, buying IoT-enabled devices and getting connected to the cloud. I started off just like anyone else, totally oblivious to all these things, not to mention that I live extremely far away from the hub of all these changes. But, I will try to share what I have learnt and we will go off on this journey into the world of home automation.

As with any journey, we need to start off with the basic building blocks of home automation, and with that I present to you a company from China (itead) that produce a brand known as Sonoff, which with the help of the Internet, we will flash it so that it only listen to us and will not send back any information whatsoever to a foreign country.

There are plenty of ways to flash it, ranging from the easiest to the hardest, I learnt my lessons somewhat the hard way, so I will share with you, how I flashed a Sonoff 4CH.

Before you get all these, you need to get a USB-FTDI adapter, I personally use the CP2102 type and also you need the cables and metal prongs needed to connect the Sonoff to the USB outlet on your computer.

First of all, we need to download the Arduino IDE program. As of this article, it is at Version 1.8.9.

Screenshot 2019-07-11 at 10.36.35 AM

And for the code that we want to flash, I chose Tasmota. There are a few other flavours to chose from but I went with the commonest. As of this article, it is at Version 6.6.0

Screenshot 2019-07-11 at 10.46.38 AM

Unzip both and open up your Arduino IDE application, there are a few things we need to set up before we can start editing. First, go into >Preferences and paste this into the ‘Additional Boards Manager URL’ : http://arduino.esp8266.com/stable/package_esp8266com_index.json

Screenshot 2019-07-11 at 12.39.57 PM

Next, go to >Tools >Board >Boards Manager

Screenshot 2019-07-11 at 12.42.41 PM

(Don’t worry if yours doesn’t show up as many as mine did, I have already downloaded the libraries, that’s why I have so many choices)

Due to the URL you entered above, you will be able to download the ‘esp8266’ boards library whch is at Version 2.5.2. This might take awhile, so go and get yourself a cup of coffee, a screwdriver (Phillips-head) and a marker pen.

Screenshot 2019-07-11 at 10.53.42 AM

In the meantime, you could also go to the unzipped Sonoff folder and copy all the files under the ‘lib‘ folder into the Arduino ‘libraries‘ folder. You can find the location of this library folder by looking at the >Preferences page on your Arduino IDE.

In the Arduino IDE application, navigate and open the ‘sonoff.ino‘ file and from there, click on the ‘inverted pyramid’ logo located at the far right corner and select ‘my_user_config.h‘ or ‘user_config.h‘ the latter is found in the older versions of Tasmota.

There are only a couple of lines that you need to edit as per your own requirements/settings.

  1. PROJECT – put a specific project name for each different sonoff that you flash. If you can’t think of any just put sonoff-1, sonoff-2, etc. This is where the marker pen comes in handy, write it on the cover of your Sonoff.
  2. MODULE – depending on which Sonoff you are flashing, you need to change the parameters here, I’m using a Sonoff 4CH, so I put in the code for it. You need to look at the ‘sonoff_template.h‘ to choose the code for your Sonoff, you CAN’T put your own naming profile here.
  3. WIFI – next up, set all your wifi address as per your service provider’s information
  4. SSID – same goes for here too, setup your own SSIDs and passwords for your Sonoff to connect to.
  5. Once done, click on SAVE.

Screenshot 2019-07-11 at 12.52.20 PM

Now we are set for flashing. Unscrew your Sonoff 4CH or any type of Sonoff to expose the inner parts.

Make sure your FTDI adapter is set to 3.3v, connect GND to GND, TX to TX, RX to RX and 3.3v to VCC. Note the FW/I00 button, this is the one you need to press in order to get it to go into flash mode.

Take note of these settings, some Sonoffs use the 8285 module, so remember to change it when you switch them. The important ones are:

  1. Board – make sure it’s the right module
  2. Flash Size – 1M (no SPIFFS)
  3. Flash Mode – DOUT
  4. Port – USBtoUART (since I’m using CP2102, it could be different for other FTDI adapters)

Screenshot 2019-07-11 at 12.13.10 PM

Okay, this is the tricky part if you aren’t nimble enough. Hold down the FW/I00 button and plug in the USB at the same time. At the same time. There’s no chime (on the 4CH) or any indication but certain Sonoffs might flash green. If you can flash, that means it worked. You don’t have to hold down the entire time, just a few seconds only then release the button. Click on ‘Upload’ on the Arduino IDE application and this will appear …

Screenshot 2019-07-11 at 12.21.32 PMIf you can’t get it the first time, no worries, just unplug the USB and go at it again. 9 times out of 10 it flashes perfectly.

Before you start shouting in joy, you need to test it out. Unplug only the TX and RX cables. Find out which IP address it is using on your network and open up your browser and log in. For example, mine was given 192.168.2.35, so type the IP address on the browser and you will be brought to the Tasmota page, change the type of your Sonoff accordingly via ‘Configure’ and you can click on the ‘Toggle’ button and see whether it works, try it both ways (press on the physical button and click on the browser button). Presto!

Now to flash the rest of the Sonoffs! Good luck.

We will set up the MQTT on another day.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s