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. 🙂
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.
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. 🙂
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
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.
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.
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.
The script then mostly runs...
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.
First, you will be informed of the associated risks. Read these instructions and confirm them if you agree.
A few running services will then be checked and, if necessary, terminated. 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 starting to get serious. After pressing “Enter” the flashing process would start. However, first you should put your Tuya device into flash mode. You can see an example of this in the following video.
Now you can start the flashing process with “Enter”.
The script then starts the configuration and flashing process.
This may take a while...
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.
Now confirm the security query 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 how to correctly configure the popular “Gosund Sp111” or “Blitzwolf SHP6” sockets.
After you have configured the WLAN access data for your newly flashed Tasmota device, you now have to go to 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:
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 password you have set.
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 a little deeper 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 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 you will also receive reports about current consumption.
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.
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. 🙂