Flashing devices with the ESP8266 is already described in the article ESP8266 – Flashing .bin files under Windows with the “Esptool”. But many ready-made SmartHome devices such as various sockets offer a somewhat more convenient way of flashing an alternative firmware (for example 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). In addition, the socket (or the respective device you want to flash) must be supplied with the Tuya firmware. The Tuya firmware is installed on almost all cheap SmartHome sockets from Asia. This firmware contains a bug, which makes it possible to easily install an alternative firmware via WiFi.
Everything you need to know is described in the following article. 🙂
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Before you start with this article, you should have prepared the RaspberryPi so that it can be reached via the network and controlled 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
– none –
Install the necessary software on the RaspberryPi
So that you can use Tuya-convert, you have to configure the necessary software, of course. You can download these from a Git repository. To do this, just follow the steps below.
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 use the package you just installed to download the actual files of the Tuya convert script. 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 switch to the Tuya-convert folder with the following command.
All necessary files are now contained in this folder.
Install required packages
It continues with the installation of the required packages.
Before you can start you have to run a configuration script. This will install and configure the necessary packages. To do this, enter the following command.
Most of the script then runs …
As soon as it is done, the following message appears:
“Ready to start upgrade”
Start the flash process
After all the preparations, the actual flash process can begin. There is also Tuya-convert with a very practical script. This guides you through all the important points and the flash process is really very 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 flash process, the WiFi interface of the RaspberryPi is used to establish a connection to the device to be flashed. Your connection to the RaspberryPi (via WiFi) would be interrupted.
How to find out the IP of a device in the network is described in the article View/find out the IP address of the devices in the network.
To finally start the flash process, you have to start the flash script with the following command.
The first thing you will be made aware of is the associated risks. Read these instructions and confirm them if you agree with them.
Then a few running services are checked and terminated if necessary. You have to confirm this with a “Y” and “Enter”.
On my RaspberryPi, for example, my running MQTT server was shut down.
So now it’s getting serious. After pressing “Enter” the flash process would start. First, however, you should bring your Tuya device into flash mode. You can see an example of this in the following video.
Now you can start the flash process with “Enter”.
The script then starts the configuration and the flash process.
This can take a …
Status messages will be given to you in between. But it only becomes really important …
… again when asked which alternative firmware you want to flash to the sockets. You have the choice between ESPurna or Tasmota. So give the number for the firmware you want.
Confirm the security query again with “Y” and “Enter” …
… and wait until the flash process is finished.
Once the flash process is complete, you can exit the script or flash another socket.
Important configurations for a “Tuya socket”
The following part contains a few important information about the correct configuration of the popular “Gosund Sp111” or “Blitzwolf SHP6” sockets.
After you have configured the WiFi access data for your Tasmota device that you have just flashed, you must now call up 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 this out is described in the article View/find out the IP address of the devices in the network.
Then click on “Configure Other”
And enter the following template configuration in the “Template” text field:
Also remember to tick the “Activate” box.
At this point you can of course also set a “Web Admin Password” or the name of the device.
Once you’ve entered everything, click on 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 …
… redirected to the start screen.
Here you can already see the first measurement data and also switch the socket on and off.
Now scroll a little deeper and switch to the “Console”.
There you should now make a few settings.
For the first setting you enter the following in the input line and confirm it with “Enter”
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, too, you will receive messages about the current consumption.
Last but not least, it makes sense to reduce the time between the measured values. The smallest possible setting is 10 seconds. You can set this with the following command.
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. 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 appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂