Flashing an LED on the ESP32 board with Tuya Link SDK

Tuya is an all-in-one IoT platform that enables the user to build smart IoT solutions by connecting devices efficiently, securely and reliably. This is a getting started article for configuring the Tuya platform with ESP32 cards from the Espressif via the tuya link SDK. In addition, we use it to control an LED through an Android device. When the switch of the Tuya Smart app is on, the LED connected to the ESP32 board will light up and vice versa.



  • ESP32 board
  • LED with suitable ballast resistor
  • Breadboard, micro-USB cable and connection wires


GitHub link: https://github.com/JayeshRajam/Tuya-ledapp.git

The ESP32 card is placed on a model. The positive terminal of the LED is connected to digital pin 5 of the ESP32 board and the negative terminal is connected to the ground pin through the ballast resistor as shown in the following circuit diagram.

Hardware connections of the esp32 card for tuya link sdk

Software configuration: Tuya IoT platform

Log into your Tuya account or if you don’t have an account, create one using the Sign up option.

Tuya login page

Once logged in, a preview of the platform is visible. Click the Create button to start a new project.

Tuya dashboard

To develop the application for ESP32 click on ‘Can’t find the category?’. The following custom creation menu should appear.

Creation of custom categories Tuya

Fill in the required fields as shown above and click Create. A pop-up will appear, just close it to get the following screen.

Tuya function dashboard

Here we will add a custom function of the following parameters.

Custom function creation

Click on OK. The function will now be visible.

Tuya link SDK custom function visible

The graphical user interface (GUI) of the Tuya smart application now needs to be developed. To do this, simply go to the Device Panel tab and select “Create Empty Panel”.

Device panel tab

Here are the steps to complete the UI Studio procedure.

You can always test and publish the app before going any further. You can also visit this article to learn more about the Tuya platform for designing and manufacturing smart home solutions.

Note: The test procedure requires you to install and log into the Tuya Smart app on your Android and enter the same email login ID here.

Testing and publishing the user interface

User interface testing processOnce back on the Tuya IoT platform, it is now time to generate a license for Link SDK.

license generation for link SDK

Select Link SDK Cloud Access Mode on the Hardware Development tab. Click on the “Select” button provided to place the license order. Click on “Get 2 free licenses” and follow the steps to finally download an .xlsx file with uuid and key.

Now is the time to install tuyaos-link-sdk to benefit from connectivity to Tuya Smart Application via Python 3.x. On your Windows PC, run the following commands to clone the GitHub repository and install the tuyaos-link-sdk.

tuyaos-link-sdk install python

Open the ledapp.py file from the GitHub repository in the editor. Modify and modify the productid, uuid, authentication key and COM port of your connected ESP32 device in the file. We will use this file later in the output section of this article.

Software configuration: Tuya smart app

Install the Tuya Smart app from the Google Play Store on your Android device.
Tuya Smart App Google Play Store

Log into your account or if you don’t have one, create one!

Login to Tuya Smart account

Now in the add device section, click on the scanner button to scan the QR code generated by the ledapp.py file.

Tuya smart addition device Tuya Smart Add device options

Tuya Smart Scan

Now the ESP app will be added to the All devices section of the Tuya Smart app.

ESP Tuya Smart App

The Arduino IDE here is used to process the serial message from the Python desktop to the ESP32 board in the same way as the built-in PhysicalPixel example.
Add the ESP32 board in the Arduino IDE

Arduino ESP32 IDE Boards

Map Manager URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json

When the incoming byte on serial is “H”, the program turns on the LED. The LED is off when the incoming byte is “L”. Remember to set the correct GPIO pin that the LED is connected to.

To go out

Run the ledapp.py file using the command

Link Tuya SDK Exit 1.jpg

Tuya link SDK Exit 2

Harry D. Gonzalez