The open-source Raspberry Pi is very popular with global developers. This project describes how to quickly connect the Raspberry Pi to Tuya Cloud by using the TuyaOS Link SDK. Therefore, Raspberry Pi-powered devices and ‘Powered by Tuya’ devices can be linked.
StepsStep 1: Create a productYou can create a product on the Tuya IoT Platform and get a unique product ID (PID)
1.Log in to the Tuya IoT Platform.
2.Click Create.
3.Find Standard Category, scroll down to the bottom of the page, and click Can’t find the category?.
Note: Because the Raspberry Pi is a non-standard category, you need to select Can’t find the category? when you create a product.
4.Enter the product information and select Wi-Fi as the protocol type, and click Create Product.
5.Get the PID information.
Tuya devices communicate with the cloud through data points (DPs). We need to add the DP ID according to product functions, and then configure related information.
Note:The Tuya IoT Platform currently supports six data types, including Boolean, Integer, Enum, Fault, Char type, and RAW type. For more information, see Custom Functions.Because the Raspberry Pi is a non-standard category, only custom functions can be added in this step.
1.In the Function Definition > Custom Functions section, click Create Functions.
2.In the Newly create custom function pop-up window, enter the relevant information of the DP and click Confirm.
3.The created function will be displayed in the Custom Functions section.
You can view the data that is transmitted between the device and the cloud on the app. Select the debugging panel for the Raspberry Pi. For more information about specific operations, see Debug panel in Design App UI.
Note: Because the Raspberry Pi is a non-standard category, only the debugging panel is applicable.Step 4: Get licenses
1.In the Hardware Development tab, select the Self-developed Module SDK, and set the required fields.
2.In the Develop SDK section, keep the default settings for Chipset Platform, Operating System, and Toolchain, enter a module name, and then click OK.Wait a minute. The page will refresh and the free licenses will be displayed.
3.On the right side of the Selected Module section, get free licenses.
The SDK provides a demo that runs in Ubuntu. The following shows how to run the demo.
1.Write the PID and license to the examples/linux/switch_demo/tuya_config.h file in the demo, and set the macros TUYA_PRODUCT_KEY, TUYA_DEVICE_UUID, and TUYA_DEVICE_AUTHKEY.
2.Install an integrated development environment and run the demo.
1) Install make and other related dependencies.
sudo apt-get install make cmake libqrencode-dev2) Clone the code from the repository
git clone https://github.com/tuya/tuya-iot-link-sdk-embedded-c.git --recurse-submodules3) Create a file and compile it.
mkdir build && cd build
cmake ..
make4) Run the demo. Let’s take the switch demo in the SDK as an example.
./bin/switch_demo3.Search for Tuya Smart or Smart Life in the App Store or Google Play to download the Tuya Smart or Smart Life app.
4.Bind a device with the app.You can use the app to scan the QR code generated by the program on Linux to bind a device.For more information, see IoTOS Link SDK Overview.
SummarySo far, the Raspberry Pi is connected to the Tuya Cloud and can be linked with ‘Powered by Tuya’ devices. Next, create some cool products and awesome scenarios with your wonderful imaginations.




Comments