Menu Close

Tuya Convert Guide – Flash Tuya SmartLife Devices

Tuya Convert Guide

Tuya Convert is the solution for OTA flash of Tuya based software.

Have you ever seen cheap smart plugs on Amazon like these and wondering if you can use them with OpenHAB or even Home Assitant?
You don’t want to rely on some less then secure cloud service to toggle your smart plugs?
You are not good at soldering and would like a OTA solution?

If you have answer yes to any of these questions, you’re in luck! Tuya Convert is here to save the day!

This post may contain affiliate links.  If you make a purchase I may get a commission at no cost to you.  Please see the Disclaimer for additional information.

A Little Bit of History

Looking into a way to cheaply automate some of my gardening equipment, namely the lights of my nursery and indoor garden and my automatic irrigation, while I waiting for the hardware for a more complete DIY solution, I found those cheap smart plugs.

Freedom from the Cloud

However, I am not a big fan of these Chinese smart device connecting to a cloud which I have no control over and no trust. I already knew that you could pop one up and using soldering skill and a FTDI serial converter and some custom firmware such as Esphome and Tasmota. However, I am not that good at soldering and luckily found out Tuya-Convert! Using this custom firmware, an Home automation system, like OpenHAB, and MQTT you can control these smart devices without using any cloud based software.

Smart Home Automation

Once the device is freed from its firmware and cloud based companion app, you can use it to automate something in your house!
Currently, I use them to automate my garden irrigation, my indoor garden and some light thanks to some smart switch socket.

Tuya-Convert Project

Tuya-Convert is a project which allows you to replace the firmware on Tuya based smart devices with whatever you want. In this case, Tasmota is used as the custom firmware.

Tuya Convert walthrough and guide

Equipment

Raspberry Pi 2 or Newer (2, 3, 3B+ or 4)
32GB MicroSD card (if you don’t buy a Raspberry Pi kit)
USB Keyboard (if not using SSH)
USB mouse (if not using SSH)
USB Keyboard and mouse combo (if not using SSH)
HDMI Cable (if not using SSH, Raspberry Pi 3B+ and lower)
HDMI Adapter (if not using SSH, Raspberry Pi 3B+ and lower)
Mini HDMI Cable (if not using SSH, Raspberry Pi 4)
Mini HDMI Adapter (if not using SSH, Raspberry Pi 4)
Ethernet Cable (if no Wi-Fi is availlable)
Wi-Fi Dongle (optional)
Raspberry Pi Case (optional)

Tuya based favorites

Gosund Smart Plug,
Motorized Blinds,
Touch Switch Panel,
4 Pack mini smart plug,
Smart bulbs.

Additional Links

Raspbian Buster Lite,
Etcher Link,
Putty Link,
Tuya Donor Files,
Tasmota,
EspHome,
ct-Tuya-Convert Github.

Before you begin you’ll need: A wifi device that can connect to the SSID that will be generated by the raspberry pi and eventually the flashed tuya device.

Installing the OS on Raspberry Pi:

I found that I had less issues using Tuya-Convert on a fresh OS, and it’s not that hard to install a fresh OS on a Raspberry Pi. I would suggest that you keep a microSD card with an almost bare OS just to use to with Tuya-Convert.

On a fresh Raspberry Pi OS load, I like to expand the file system and do a full package and distro update. As such, if it’s not already done, you should run sudo raspi-config and under “Advanced Configuration” select expand the filesystem to fit the whole SD card.

Additionally, you will need the git package to download the latest version of Tuya-convert.
As such, you will need to install that at the same time.

# Expand filesystem under advanced configuration
sudo raspi-config

# Fetch Update and upgrade all the packages
sudo apt-get update
sudo apt-get dist-upgrade -y

# Install git
sudo apt-get install git

Install Tuya-Convert

Since Tuya is availlable on github as free code, we will use git to clone the repository directly on your Raspberry pi.
In the SSH or terminal window, navigate to the location you want to clone the repository.
And, clone it with the command:

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

Once the Tuya-Convert clone is ready, it’s time to install the rest of the dependencies.
Luckily, the developers got your back and the project comes with a script that install all dependencies. As such, enter the tuya-convert directory and run the dependency script:

cd tuya-convert
./install_prereq.sh

The script will run for a while installing the dependencies necessary to run the code.
Once the job is done, you will see the following message:

Successfully built sslpsk
Installing collected packages: sslpsk
Successfully installed sslpsk-1.0.0
Ready to start upgrade

Tadam! Tuya-Convert is ready to use

Use Tuya-Convert to install Tasmota

Now that Tuya is ready for use, it’s time to start running it and actually reflash your device with your custom firmware!
In this case, we will use the Tasmota firmware that is availlable in the repository.
Also, If you compile your own firmware, you need to include it in Tuya’s files directory.
And, it’s the same directory that also houses the Tuya provided firmwares. You can use a USB key or do it over SSH if your Raspberry pi is on the same network.

I have noticed that it’s sometime hard to use tuya-convert with SSH, it’s seems that with the tools I am using, the screen command isn’t working properly.
As such, I am using TeamViewer to connect remotely to my headless Raspberry Pi Raspbian UI.
If you want to install it, read this Installing TeamViewer on your Raspberry Pi guide.

Once you have a connection to your Raspberry Pi using TeamViewer, you need to open Terminal.
The process is easy to start and everything is almost automatic. Firstly, you need to start the actual flashing process with:

./start_flash

And, you should see a warning message that the process might render your device unusable. Usual legal thing to do when you provide software and code.

=====================================================
PLEASE READ THIS CAREFULLY!
======================================================
TUYA-CONVERT creates a fake update server environment for ESP8266/85 based tuya devices. It enables you to backup your devices firmware and upload an alternative one (e.g. ESPEasy, Tasmota, Espurna) without the need to open the device and solder a serial connection (OTA, Over-the-air).
Please make sure that you understand the consequences of flashing an alternative firmware, since you might lose functionality!

Flashing an alternative firmware can cause unexpected device behavior and/or render the device unusable. Be aware that you do use this software at YOUR OWN RISK! Please acknowledge that VTRUST and c't Magazine (or Heise Medien GmbH & Co. KG) CAN NOT be held accountable for ANY DAMAGE or LOSS OF FUNCTIONALITY by typing yes + Enter

If you understand and are willing the take the risk, which is minimal, simply type yes and press enter to continue.
Depending on how you have set up your Raspberry Pi, the tool might detect that dnsmasq and mqtt are running on the Pi.
Actually, there is no issue, just allow the tool to terminate those 2 processes by typing “y” and allow it to continue the flashing process.

Checking for network interface wlan0... Found.
Checking UDP port 53... Occupied by dnsmasq with PID 6934.
Port 53 is needed to resolve DNS queries
Do you wish to terminate dnsmasq? [y/N]

Checking TCP port 1883... Occupied by mosquitto with PID 9532.
Port 1883 is needed to run MQTT
Do you wish to terminate mosquitto? [y/N]

Once the script completes its duty, it creates a new access point called vtrust-flash.
You need to connect your secondary Wi-Fi device to this new vtrust-flash access point.

If the Raspberry Pi ask you for a password to connect, it’s “flashmeifyoucan”. To flash your Tuya based device, it needs to be in pairing mode. How to achieve this mode will depend on your device.

It could be to hold the power button until the blue light flashes rapidly, or switch the light on and off several times until they flash.
For the exact method, you should refer to your smart device user manual.

As soon as the Tuya smart device is in pairing mode and that your other device connects to the vtrust-flash access point, you can press enter on your SSH acessing tool. This will launch the flashing process and all you need to do is wait the process to complete. You will see some outputs and then Tuya-Convert will back up the smart device firmware and will ask you for the new firmware to flash.

For your convenience, the following firmware images are already included in this repository:
    Tasmota v7.0.0.3 (wifiman)
    ESPurna 1.13.5 (base)

You can also provide your own image by placing it in the /files directory
Please ensure the firmware fits the device and includes the bootloader
MAXIMUM SIZE IS 512KB

Available options:
    0) return to stock
    1) flash espurna.bin
    2) flash tasmota.bin
    q) quit; do nothing
Please select 0-3:

In this case we select the second option to install Tasmota firmware onto our smart device. Some more waiting is require, but in once the script finishes its work, your smart device is ready to use with a brand new firmware!

And Voilà, a smart device free from the cloud.

Tasmota Quick guide

It’s now time to configure your new Tasmota smart device.
Once this is complete, you are now ready to start controlling your device using MQTT and your OpenHAB or any other Home Automation software.

And don’t forget: Keep the dream alive!

Enjoyed this post?

Follow us on Pinterest for additional awesome ideas!​

Some posts on this blog contain affiliate links.
At no additional charge to you, I receive a small commission whenever a product is purchased through these links. The Dreaming Dad is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.