Tuya IoT platform is an all-in-one new generation IoT platform to build IoT projects for various sectors like- Home automation, Healthcare, agriculture, education, Smart Security and monitoring systems, and many more. Tuya IoT platform encourages New Entrepreneurs to start their business based on the tuya IoT platform easily.
For example, if you are in a Home automation business want to build smart home products, apps for your own brand you can create them easily within a short time.
About Tuya Link SDK Project:In this project, I will show you how you can make a smart home device with ESP32 to control some electrical devices without using any extra tuya wifi module. I will control Christmas light as an example you can control as many devices you want as per ESP32 GPIO pins like -10 to 15 devices. In this project, I will use Tuya Link SDK to connect devices to the Tuya IoT platform.
Tuya Link SDK Project Requirments:Hardware:- ESP32 Module-1 Piece[source]
- USB Cable - 1 Piece [source]
- Breadboard ( not required for Direct Connection) [source]
- Some female to female Jumper wire / connecting wire. [source]
- 1 or 4 Channel 5 volt Relay Board - Pice [source]
- Christmas Light [source]
- Git (download)
- Python 3.10 or 3.x.x (download)
- Arduino IDE (download)
- Tuya IoT Platform Developer Account
- Tuya Smart App
To start the project you have to create a developer account on the Tuya IoT Platform. Go to Tuya.com and click the “Go to IoT Platform” As shown in the image below.
After you click the button you will land on the login/signup page, from there you fill the form and create the account.
Create A Product On Tuya IoT Platform:Log in with your new account once you logged in you will see this page, to create a product you have to click on this create button-
After clicking the Create button you will land on this page,
Here you have to specify the project type, as we are making a custom product with ESP32 board you have to select “Can’t Find any Category?” Option. Once you click on it it will take you to this page-
Here you have to fill up and select some properties of your products like Communication protocol, Power consumption, Products Name, Description, and Product model Some of them are mandatory and some are optional. Give a cool name and model to your product. Write some info about your products in the Product description section and select the power Type as shown in the image. The most important part is the communication protocol Select the “Wi-Fi” option for it, otherwise, you will not be able to find the Tuya Link SDK in the next step. Once you finish with all of those things click on the “Create” Button. After clicking the create button you land on this page with a popup window like this one-
Just click the “Ok” button without doing or selecting anything because we are going to build a custom device we will define our own function on the name step. Once you have clicked on the “OK” Button you will land on this page-
Here you can see the LinkSDK is selected by default, now you just have to add some custom functions just by clicking on the “Add” Button in The custom function section. You can add as much you want as per your needs also per the GPIO Pins of your ESP32 module to control the loads.
By clicking the ADD button you will see a pop-up from the right side where you have set the function properties-
Type and select the “DIP ID”, “DIP Name”, “Identifier”, “Data Type” & “ Data Transfer Type” according to the image. I have added 1 function to control my 1 channel relay.
To design the device panel for your device you have got to the Device Panel section by clicking the “ Device Panel” As shown in this image below-
From the device Panel page select the “ Create Blank Panel” Option to design your device panel from scratch. Once you click on it, it will open a new tab to take you to the UI Studio Page. Where you will design the device panel like this page below-
It will give you some introductory tour as you are now to UI studio. Once your Finish your tour this page will pop up as shown up. Select the Fullscreen Scrolling Option you will land on this page-
button as I have shown in this image. I hope you can see there is my light by the name of dp_light_1 on the left side as I have defined in the custom function section before, and next to it there are controls. Controls are actually the type of buttons you want to use for each function to control your loads. You just have to drag and drop those buttons on the main panel.
Here is mySimple Design-
Once you are finished with your device panel design it’s time to release it. To release the panel click on the release button on the top right corner as shown in the image below-
Once you click on the release button a pop-up will come from the right side to fill up some info about the panel fill it up and click the “OK” button.-
Once you click on the “OK” button Tuya IoT platform will start the processing work for your device panel which has 7 steps like this image below-
Once it finishes its work you will land on this page, the next step will be the “Test UI“ Where you can Test the UI or can release it directly without Testing the UI.
Click on the “Test” Button if you want to Test the UI or click the “Release” Button. I have selected the Release button to release it directly.
Once you finish releasing your UI, you can start the hardware part. Click on the Hardware development section then make sure the “ LinkSDK” is selected. Now you need to click the select button to get the device license. You will only get two free licenses as a new user. Do the same as shown below-
Once you click the select button you will land on this page-
Here you need to click on “ Get 2 Free licenses” which is $4 for free from the Tuya IoT platform. Once you click the “ Get 2 Free licenses” link a new tab will open like this one-
Select the “ License List” from the drop-down and click confirm button. Then you will land on this page-
Just click on Submit Order button to submit the order request. Then you will see this page that shows the order is submitted successfully-
Now click on “View Order List”. It will not take that much time as it shows that it will take 3-5 days. It took not even a min for me to process the order. Once you click on View order list you will land on this page-
From here copy the product ID and save it to use in device code. Also, download the licenses by clicking the “Download license list” Button. Once you click it an xlsx file will start downloading. Keep it in a save folder so you can find it later.
Hardware Setup & Device Programming:
Connection Diagram:
PC Setup:
Now it’s time to install Python 3.10 or 3.x.x (download). I have downloaded Python 3.10 and installed it on my windows PC.
Once you installed the Python on your PC, it’s time to install another program called “Git”. Go to this link and download then install it on your PC too.
I hope you have finished installing both, then we can start the main part of our setup, which is Downloading & installing the Tuya LinkSDK Github repository on our PC. TO clone and install the repository you need to type these two lines one by one on your PC through the “CMD” program.
Line 1: git clone https://github.com/tuya/tuyaos-link-sdk-python.git
Line 2: python -m pip install./tuyaos-link-sdk-python
Programming & Device Setup:
Code:
I have added all codes for the device and for the Tuya IoT connection on my GitHub repository. Download the code and keep it on your desktop to access it easily.
Device Code Uploading:
Change the pin number according to your connection then save the code and Connect your ESP32 module to your pc and Set the Budrate according to the code and upload the code.
Now it’s time to run the Python code, Open CMD (command prompt)non your PC. But before running the Python code fill up the Product ID, UUID, and KEY inside the code and save it.
Change the directory where you have downloaded the code, I kept it on desktop and in a folder called Tuya. So, Type it according to your setup and press Enter.
Now on that folder, we will have a python script which I saved by the name of “lightho.py”. Run that script by typing this on your CMD.
Once you press enter button it will try to connect to the Tuya IoT platform upon successful connection it will generate the QR code so you can add the device to your Tuya Smart APP.
It’s time to install the Tuya Smart App from the Google Play store.
Install it and sign up with your Email ID. Once you are finished with the signup it’s time to add the device by scanning the QR code which is on your CMD.
Adding Device to Tuya Smart App:
Step 1: To add the device open Tuya smart Appand click on the Me tab….
Step 2: Then it will take you to this page- where you need to click on the Scan button to scan the QR code-
Step 3: Scanning the QR is very fast, once it is scanned the QR code device will start adding to Tuya smart APP-
Step 4: Once it’s added to your Tuya smart app it will look like the same as you have designed in the Tuya IoT platform click on done and control your light-
Video:
Comments
Please log in or sign up to comment.