Riproset an ITEAD switch Sonoff Basic using firmware Tasmota

9 minutes of reading
AIMS OF THE GUIDE
  • Riproload a device ITEAD Sonoff Basic with the firmware Tasmota (la procedura is also valid for others proITEAD line productsSMART HOME"And for other similar firmware for ESP8266), thus making it compatible with the proProtocol MQTT (therefore indirectly with the best known HUB personal).
  • Difficulty level: medio
CONCEPTS FACED:
  • riprofirmware grammation
SOFTWARE COMPONENTS USED:
Physical devices used:
GUIDE MOST INDICATED FOR:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere progettata ed effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.
Driving review: 1.1

ATTENTION: the images in this guide refer to the first version of Sonoff Basic (R1) not the second (R2). Nevertheless, the riproming it is the same, as the contacts on which to settle for the reprogrammation are the same both on the R1 version and on the R2.

ATTENTION: this guide it is more than enough for the purpose of reprocalculate the component; in the event of proproblems, refer to the broader and more structured MasterGuide dedicated to the reprogrammation of devices based on ESP8266, in which many more concepts and techniques are explained (including the new DIY via OTA).

Abstract

Every electronic device contains broadly a small piece of softwareCalled firmware, which determines its functions and behavior.

Our car is equipped with firmware; it has one, the washing machine, our remote control, even a modern clock radio. The Sonoff Basic and all his brothers make no difference; the point is that the original firmware has some inherent limitations: allows this intelligent switch to work only via the internet connection to the site of the proproducer, cannot be natively integrated on the most common HUB personal, does not support prothird parties

To our aid intervene - among the various existing - the two proOpen Source jets, respectively called Sonoff-Tasmota e Espurna, which provide us with alternative firmware which, once installed on the device, allow it to expand the profunctionality. On this page we will focus on the installation of Sonoff-Tasmota. To do this you need a computer, a connection device between the computer and the computer Sonoff (Called USB / TTL adapter) and a software on the computer (for this guide we will use ATOM) to perform the procedura of proprogramming.

Riproset an ITEAD Sonoff it is generally a great idea: the fact that the same proves it propublisher publish on profirst blog articles about it. The riproming disconnects the devices from the constraint of being usable in the presence of the internet connection (to the cloud of theapp eWeLink), in addition to extending compatibility and functionality to extraordinary tools such as HUB personal.

That said, i Sonoff generally used devices are also valid as they arrive profactory settings. Simply, they don't do some things and, above all, they can't be integrated with our loved ones HUB personal.

This guide is dedicated to the reprogrammation of Sonoff Basic, but it is applicabile in the exact same way to all the other devices in his family ITEAD Sonoff Smart Home: the only difference lies in finding, in each device, the four contacts on which to interface for firmware upload.

We have dedicated un FOCUS on the subject of control post-riproming.


ITEAD Sonoff BasicATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Sonoff (and more generally to devices ESP8266), for any doubt, question, information on the specific merit of these components.
There is a lot of talk about it chatting.

Prosubsidence

  1. Description prosubsidence
  2. Installation and configuration ATOM & PlatformIO
  3. Checking the COM port assigned by the computer
  4. Firmware download and configuration on PlatformIO Tasmota
  5. Connection of Sonoff in flash mode
  6. Upload the firmware to the device Sonoff Basic
  7. How to update OTA (over the air) a Sonoff
  8. conclusions

1. Description prosubsidence

To reprogrammare a Sonoff (Basic, but actually the proprocedure it is the same for all the other models) it is necessary, first of all, to install and configure ATOM, after which:

  • download the firmware Tasmota;
  • connect (not in flash mode) the Sonoff all 'USB / TTL adapter and, opening the "Serial Monitor" find out which COM port is automatically assigned, then disconnect the Sonoff;
  • configuration the two configuration files, "platformio.ini ”and“ user_config.h ”;
  • carry out compiling or performing the "Build" (in case of errors, correct and re-compile themprovare);
  • connect il Sonoff to the USB / TTL adapter in flash mode;
  • carry out the Update Searchnamento, or "Upload".

Let us now go into detail.

2. ATOM installation and configuration

Download and install the software ATOM at this link: https://atom.io/. This software is available free of charge for all major platforms (Apple, Windows and Linux). Once installed, it must be configured by installing the additional package called "platformhyoid"
To do this, go to:

  • Mac OS X, Menu : To Tom > Preferences > install
  • Windows, Menu : File > Settings > install
  • Linux, Menu : Edit > Preferences > install

and in the search hole search, appanointed, "platformhyoid". Once you have found the package, click on Install.

ATOM install packages
scroll to zoom

After installation, close and reopen ATOM, which at this point will start the PlatformIO package by default, necessary for riprogrammare the Sonoff Basic. The software prowill be able to install a series of additional packages completely automatically.

At the end, PlatformIO will ask to restart for one last time ATOM.
(Ed. From here on we will refer directly to PlatformIO, meaning it as ATOM + PlatformIO.)

3. Checking the COM port assigned by the computer

An adapter USB / TTL (FTDI) it is a simple device that allows us to put in communication our computer and the heart of the device Sonoff Basic. To do this, it is first necessary to "undress" the Sonoff removing the white plastic shell that it protegge. This done, the device appare as follows:

scroll to zoom

The adapter, which can vary in shape and colors, has a USB port and four contacts as standard which go contacted with those present on the board of Sonoff using gods Dupont connection cables:

WARNING! DO NOT CONNECT TO THE SIMULTANEOUSLY SONOFF TO THE USB / TTL ADAPTER
AND TO THE NETWORK CURRENT 220V!
REMEMBER TO DISCONNECT THE MAINS CURRENT FROM THE DEVICE !!!

It is usually used to weld on the board of Sonoff of the pins so to make the connection to the FTDI easy, but it is enough place simple contact pins to get the same result.

The following video shows how to connect the FTDI without the use of welds:

A further, last alternative without welding is that of "fresh laundry", available here.

Other connection techniques can be read here.

Connect therefore the module Sonoff to the USB / TTL adapter and it, in turn, to a USB port on the computer via the cable.
Then select the menu item "PlatformIO> Serial Monitor". A fi will opennestlike the following:

After a moment, in the entry "Port (The Harbour District)”Will indicate which COM port the computer has assigned to the USB / TTL module.
Take note of it.
Now disconnect the module from the USB port.

NOTE for users Apple: Atom, su macOS, could identify a different port from the classic COMx. To understand how to configure the door in this series, refer to to this thread. Beyond what is expressed in the link, always remember to install the correct driver for Mac by the profirst USB / TLL adapter.

After installing the correct driver, in the system report of the Mac, under USB, you will need to (by connecting the USB / TTL adapter) a voice as follows:

FT232R on Mac

4. Firmware download and configuration on PlatformIO Tasmota

At this point it should be downloaded the latest firmware version Tasmota.
Once downloaded, unzip the .zip file where you prefer.

Now, in the PlatformIO menu, select "Fillet > add Project Folder"And then select the folder where the zip file mentioned above has previously been unzipped.

By doing so, PlatformIO will open the projet Tasmota.

At this point it is necessary to "configure" the software package. In fact it is provided "basic", without customizations, which are necessary so that, at the end of the programmation, the Sonoff can operate correctly.

Specifically, the proprocess is the following:

  • choose which firmware component Tasmota fill in;
  • indicate the name and password of the Wifi in which the Sonoff will have to "enter" automatically once againproprogrammed;
  • indicate the COM port to be used for data transmission;
  • compile the firmware;
  • write it on the device.

To choose which part of the firmware to compile, open the file on PlatformIOplatformio.ini"And make sure it is configured only"env_default = sonoff”As in the image:

scroll to zoom

The items commented below identify the alternatives, namely the compilation or a minimal part of the firmware (“env_default = sonoff-minimal") Or full language versions ("env_default = sonoff-E"Is the Italian one), or the standard one (appanointed, as suggested above, "env_default = sonoff“).

Search for the item "upload_port =") And enter the previously identified COM as a value to the previous step.

Once completed, save and close the file.

Now you need to configure name and password of our Wifi.

Open the file "Sonoff > user_config.h"(Or"Sonoff > my_user_config.h”Starting from the 6.3 version of Sonoff-Tasmota) and find the variables: "#define STA_SSID1" is "#Define STA_PASS1"

scroll to zoom

Enter the name there was originally the proman Wi-fi and the related password. Save and close the file.

Now we are proto "compile" our firmware package. Click on the menu "PlatformIO> Build"
If the procedura will be successful, you should get a screen similar to this:

scroll to zoom

The package is completed e proto be sent to the device.

Nb. the action of compiling ("Build") the firmware Tasmota translates into the creation of a file ("firmware.bin") At the route"% directorycontenentetasmota\ .Pioevens \sonoff". This information is useful when you want to do the next onenamento OTA (Over-The-Air), which asks to indicate the file "firmware.bin" of the new version of the signature that has been previously compiled.

A dedicated guide is available here all'aggiornameof the massive Sonoff-Tasmota with a single centralized operation, via TasmoAdmin.

5. Connection of Sonoff in flash mode

To activate the Sonoff in flash mode (or proto receive the new firmware) procedura is the following:

  • connect the Sonoff to the USB / TTL module (as explained before);
  • press and hold the gpio0 button (“Program button ”) as in the scheme above;
  • connect the cable to the computer's USB port;
  • release the gpio0 button.

At this point (e alone at this point, if you have done everything right), the Sonoff Basic Sara proto receive our firmware package Tasmota previously configured and compiled.

If the upload (prossimo paragraph) failed, riprovate this procedura again.

6. Firmware upload on Sonoff Basic

At this point it will be sufficient to select on the menu “PlatformIO> Upload”To start the phase programmation e proere. If at the end of procedura read "SUCCESS" (similarly to the firmware compilation screen), then good, you will have done correctly the first custom configuration of yours Sonoff Basic. In the case instead the procedura fail, repeat the steps above, taking care to carefully check the configuration of the COM, of the connections and all operational sequences.

Now that the procedura has been successful, it is necessary to verify that everything works properly. Disconnect the USB cable and then reconnect it immediately, this time WITHOUT hold the gpio0 button: this will cause the Sonoff is powered up and starts functioning normally without going into the mode proprogramming.

At this point the Sonoff it will be on and will have entered into the Wifi, as already informed of the access coordinates (see point 2 of the guide). To cling to it, however, it is necessary to find out which IP our router has assigned to it, something we cannot know in advance.

To do this, click on "PlatformIO> Serial Monitor”And, in the following screen:

select "Baudrate" to set "115200", while the "Port" field should automatically configure.
By clicking on "Start" dovrebbe appenter a screen as follows:

scroll to zoom

which should indicate the IP obtained from Sonoff when it entered the Wifi network, in this case "10.0.1.43". Now, opening up any browser on the proyour computer, enter the address the IP just obtained and press enter.

If all went well, dovrebbe appenter a screen as follows:Compliments!
Il Sonoff Basic is correctly reprogrammato with the firmware Sonoff-Tasmota.

It will be enough now disconnect the device from the FTDI adapter and then from the computer, restore the 220v electrical connections and start using it.

7. How to update OTA (Over The Air) a Sonoff

To update un Sonoff Basic previously proprogrammed Tasmota (actually the procedura is the same for all the ITEAD models Sonoff updated Tasmota) it's enough fill in the updated version of the firmware Sonoff-Tasmota (or this passage of this guide) and recover the file "firmware.bin"(See the item" take note "at the end of the indicated passage).

Indeed you must first compile the "minimal" firmware ("env_default = sonoff-minimal" In the file plaformio.ini), set the file aside "firmware.bin”Resulting, recompile the“ complete ”firmware (“env_default = sonoff”- or distribution language - In the file plaformio.ini) and set the second file aside "firmware.bin"

Next, connect via web browser to Sonoff e select "Sign Upgrade".

Under the heading "Upgrade by file upload", Select the file"firmware.bin"Above concerning the" minimal "version, then click the" Start "button upgrade"And simply wait for the transaction to finish. At the end, reconnect to the web interface and redo the procedura, this time passing it the file "firmware.bin”Of the“ complete ”firmware.

A dedicated guide is available here all'aggiornameof the massive Sonoff-Tasmota with one centralized operation, via TasmoAdmin.

8. Conclusions

Il Sonoff Basic it is a powerful tool, especially when it is repeatedprogramma using Tastmota or ESPurna. After being able to update it, is Useful learn to add it to Homebridge or Home Assistant.

Actually i Sonoff do not act as only switches, the functions are in fact the most disparate, as demonstrated many of our guides dedicated to proMQTT tocollo. Tale protocollo is ideal for home automation use and, for theappgreased, it is introduced on your devices Sonoff through the highernamento to firmware Sonoff-Tasmota, object of this guide.

How to check a Sonoff after having reprogrammate the firmware


ITEAD Sonoff BasicATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Sonoff (and more generally to devices ESP8266), for any doubt, question, information on the specific merit of these components.


Please comment below