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.
Preconditions
Equipment:
- ESP32 board
- LED with suitable ballast resistor
- Breadboard, micro-USB cable and connection wires
Software:
GitHub link: https://github.com/JayeshRajam/Tuya-ledapp.git
Hardware connections for Tuya Link SDK
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.
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.
Once logged in, a preview of the platform is visible. Click the Create button to start a new project.
To develop the application for ESP32 click on ‘Can’t find the category?’. The following custom creation menu should appear.
Fill in the required fields as shown above and click Create. A pop-up will appear, just close it to get the following screen.
Here we will add a custom function of the following parameters.
Click on OK. The function will now be 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”.
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.
Once back on the Tuya IoT platform, it is now time to generate a license 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.
git clone https://github.com/tuya/tuyaos-link-sdk-python.git python -m pip install ./tuyaos-link-sdk-python
idiot clone https://github.com/tuya/tuyaos-link-sdk-python.git python –m seed to install ./tuyaos–link–SDK–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.
Log into your account or if you don’t have one, create one!
Now in the add device section, click on the scanner button to scan the QR code generated by the ledapp.py file.
Now the ESP app will be added to the All devices section of the Tuya Smart app.
Software configuration: Arduino IDE for Tuya Link SDK configuration
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
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

Team of young engineers writing tutorials and developing projects related to embedded systems, IoT, advanced AI, etc.