Last Updated on : 2024-07-22 07:49:00download
This topic describes how to develop a Tuya-enabled gateway with the MCU SDK. In this process, you need to complete product creation, hardware and software development, as well as functionality debugging.
Log in to the Tuya Developer Platform and select the desired gateway product. For more information about product creation, see Create Products.
Currently, there are two solutions available: Wi-Fi (CR3L module) and Wi-Fi and Ethernet combo (THP23-X-M module).
The CR3L solution supports the downstream protocols including Bluetooth SIG mesh, Bluetooth, and others.
The THP23-X-M solution supports the downstream protocols including Bluetooth SIG mesh, Zigbee, Bluetooth, and others.
After you create a product, you can configure the function, panel, module, and firmware based on your requirements. Then, download the MCU SDK accordingly.
When developing a product, choose a solution other than No-Code Development. If your product has access to the protocol shown in the figure below, you are developing a sub-device.
The platform recommends modules based on your solution.
CR3L module solution:
THP23-X-M module solution:
After you select the module and firmware, you can purchase modules online. Your hardware engineer can proceed with the board layout design. See the following documents:
Before starting coding, you can use Tuya’s Module Debugging Assistant in MCU simulation mode to get familiar with the communication between the MCU and the CR3L module.
In the MCU simulation mode, the Module Debugging Assistant simulates the MCU and responds to commands from the module. After you pair the module with the mobile app, you can test whether the module can receive and send data point (DP) data correctly. The following steps describe how to pair the module and use the Module Debugging Assistant.
Set up the peripheral circuit according to the schematic for a minimum system.
Open the Module Debugging Assistant and import the debugging file. Choose Wi-Fi Gateway Protocol and MCU Simulation.
Connect the module to your computer by using a USB to TTL converter. Set the Serial Port and Baud Rate. Click Open and then Start Debugging to start the data communication.
If the module does not send data upon powering on, check whether the peripheral circuit of the module works as expected.
Click RESET to put the module in pairing mode. The module supports two pairing modes: Bluetooth and AP mode. Pair the module with the mobile app as instructed by the guide.
Refer to the protocol documentation in the development document to understand how data is exchanged between the MCU and the module on the Module Debugging Assistant.
The protocol consists of the basic protocol and the function protocol.
Tuya provides two options to implement the communication between your MCU and Tuya’s module.
If your MCU does not have sufficient resources or porting SDK is not feasible, you can interface with the serial protocol yourself. For more information, see MCU Integration Protocol.
For more information, see MCU SDK Porting.
After you port the MCU SDK, you can use the module simulation mode in the Module Debugging Assistant to verify the code. In the module simulation mode, the Module Debugging Assistant automatically sends the initial data to the MCU to check whether the communication works properly. An error message will be returned if any issue occurs. After initialization, you can test different functions.
The module simulation mode only verifies the communication between the MCU and the module and does not provide real networking capability. After finishing the test, you can connect the MCU to the actual module and test pairing functionality and specific features.
Debugging tools:
Device logs: Visit the Tuya Developer Platform and choose Product > Device Logs. Retrieve the backend log by device ID.
Technical ticket: Tuya provides online technical support. If the documentation cannot resolve your questions, you can submit a ticket to request technical support.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback