HowTo: Tasmota – Flash firmware with TuyaConvert

Flashing devices with the ESP8266 is in the article ESP8266 - Flash .bin files on Windows using Esptool already described. However, many ready-made SmartHome devices such as various sockets offer a slightly more convenient way of flashing alternative firmware (e.g. Tasmota) without a soldering iron.

All you need is a RaspberryPi and possibly a second SD card (if you don't want to change the current installation on the RaspberryPi). Additionally, the socket (or device in question) must come with Tuya firmware. The Tuya firmware is installed on almost all cheap SmartHome sockets from Asia. This firmware contains a bug that makes it possible to easily install an alternative firmware via WLAN.

Everything you need to know is described in the following article. 🙂


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:

Helpful articles:
Before you start with this article you should have prepared the RaspberryPi so that it is accessible via the network and controllable via SSH.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

Required tool:
- none

Required material:


Install the necessary software on the RaspberryPi

In order for you to be able to use Tuya-convert, you must of course configure the necessary software. You can download these from a Git repository. Simply follow the steps below.

Install Git

Git is already installed on most systems. If not, you can install it with the following command.

sudo apt-get install git

You can find more information about Git in the article GitHub - How do I copy files from a Git repository to my computer?.

During the installation, you will probably be asked if you agree to the installation. Confirm this with Y and Enter.

Now you can download the actual files of the Tuya-convert script using the package you just installed. To do this, enter the following command.

git clone https://github.com/ct-Open-Source/tuya-convert

The download takes a few seconds.

After you have downloaded the files, you can now use the following command to go to the Tuya-convert folder.

cd tuya-convert

This folder now contains all the necessary files.

Install the required packages

We continue with the installation of the required packages.

But before you can get started, you have to run a configuration script. This will install and configure necessary packages. To do this, enter the following command.

./install_prereq.sh

The script then mostly runs...

...automatically off.

Once it's finished, the message will appear

"Ready to start upgrading"


Start flashing process

After all the preparations, the actual flashing process can now begin. Tuya-convert also comes with a very practical script. This guides you through all the important points and makes the flashing process really easy.

I strongly recommend that you connect your RaspberryPi to your network using a network cable and also connect to the RaspberryPi via the IP address of the cable network adapter. During the flashing process, the Raspberry Pi's WLAN interface is used to establish a connection to the device to be flashed. Your connection to the RaspberryPi (via WiFi) would be interrupted.

How you can find out the IP of a device in the network is in the article Display/find out the IP address of the devices in the network described.

In order to ultimately start the flashing process, you have to start the flash script with the following command.

./start_flash.sh

First, you will be informed of the associated risks. Read these instructions and confirm them if you agree.

A few running services are then checked and terminated if necessary. You must also confirm this with a "Y" and "Enter".

For example, my running MQTT server on my Raspberry Pi was also stopped.

Now things are getting serious. After pressing the "Enter" button, the flashing process will start. First, however, you should put your Tuya device into flash mode. You can see an example of this in the following video.

In programming mode, the LED of the Tuya device to be flashed (here the Gosund SP111 socket) flashes as shown.

Now you can start the flash process with "Enter".

The script then starts the configuration and flashing process.

This may take a while...

…last.

You will receive status reports from time to time. But it only becomes really important...

...again when asked which alternative firmware you want to flash on the sockets. You have the choice between ESPurna or Tasmota. So enter the number for the desired firmware.

Confirm the security prompt again with "Y" and "Enter"...

...and waits until the flashing process is completed.

Once the flashing process is complete, you can exit the script or flash another socket.


Important configurations for a "Tuya socket"

Below is some important information on the correct configuration of the popular "Gosund Sp111" or "Blitzwolf SHP6" sockets.

After you have configured the WLAN access data for the Tasmota device you have just flashed, you must now open the configuration page of the socket and click on "Configuration".

To do this you need the IP address of the Tasmota device in your network. How you can find out is in the article Display/find out the IP address of the devices in the network described.

Then click on "Configure Other"

And enter the following template configuration in the "Template" text field:

{"NAME":"SP111 v1.1","GPIO":[56,0,158,0,132,134,0,0,131,17,0,21,0],"FLAG":0,"BASE":45}

Also remember to check the "Activate" box.

At this point you can of course also set a "Web Admin Password" or the name of the device.

Once you have entered everything, click Save.

If you have set a "Web Admin Password", you will now be asked to enter the set password.

After a short wait, you will be back...

...redirected to the home screen.

Here you can already see the first measurement data and also switch the socket on and off.

Now scroll down a little further and switch to the "Console".

You should now make a few settings there.

For the first setting, enter the following in the input line and confirm with "Enter"

VoltageSet 235

This sets the socket to the European mains voltage.

Another useful setting is the following. It enables the energy measurement to take place even when the socket is switched off. In this case you will also receive reports about current consumption.

SetOption21 1

Last but not least, it makes sense to reduce the time between measurements. The smallest possible setting is 10 seconds. You can set this with the following command.

TelePeriod 10


Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

4 comments

  1. Great tutorial ! 🙂
    But unfortunately my question is not clarified.
    How can I change the template of the Gosund SP111 so that both LED's can be used ?
    For example, shall:
    The red LED must always be on to see that the socket is energized.
    The Blue LED indicate the switching status Blue LED on = Switched on / Blue LED off = Switched off ?
    It would be great if the setup would be explained in the template. I have unfortunately given up after several hours of testing, because I did not get both LED's to run.

  2. Hello Fab,
    great site and very good (detailed) tutorial on Tuya-Convert !
    I have also been converting ESP devices with alternative firmwares for some time.
    Since October 2020, however, I have noticed that more and more devices are shipped from the factory with a new Tuya firmware, which unfortunately seem immune to the Tuya convert process so far.
    More details on the wiki page of Tuya-Convert ...
    https://github.com/ct-Open-Source/tuya-convert/wiki/Collaboration-document-for-PSK-Identity-02

    With such a firmware the search for an ESP device during the flash process remains unsuccessful.
    This seems to be increasingly the case since the end of last year, especially with ESP devices that were "imported" via Amazon. Therefore, I'm a little surprised that there are still SP111 sockets that you can successfully convert. I had at the beginning of November with the SP111 unfortunately no more luck.
    They are quite chic in terms of design, but unfortunately also very resistant to attempts to disassemble them and traditionally flash them serially.

    1. Hello Stefan,
      thank you very much 🙂
      I also noticed the same thing. The original "SP111" socket is probably no longer available on Amazon. It is always delivered a different model, which (as you have already written) is difficult to flash. However, you can still get these sockets on Banggood and Aliexpress. At least so far. Hopefully that doesn't change there as well 🙂 .
      Best regards
      Fabian

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.