The Zigbee universal solution is one of the mainstream MCU interconnection solutions. MCU only need to use the Tuya Zigbee universal serial port access protocol to quickly complete the MCU docking, so that the device can be connected to the Internet. Tuya provides complete modules, App, and cloud services during the process.

Compared with other communication module solutions, Zigbee modules require a gateway, have a short distance but low power consumption.

This article is mainly an overview of the development process of Tuya Zigbee universal solution MCU.

Development Process

The development process mainly includes: product creation-hardware debugging-software development-functional debugging.

Create Product

Log in to the IoT Workbench and create a product. Select the product category according to the actual needs, and select Zigbee for the networking method. After the product is created, you can select the functions, panels, modules, and firmware according to the actual needs of the product and then download it to the MCU development kit.

Creating a product is described in detail in the MCU Access Guide, so I won't repeat it here. For specific steps, please refer to: Product Creation-IoT Platform Operation

Hardware debugging

Hardware selection

When creating a product selection module, the platform will recommend some common module models. The most commonly used Zigbee modules in the Zigbee universal solution are TYZS3 and TYZS5.

Tuya Zigbee module, divided into strong current and weak current firmware. Strong current firmware is suitable for products with long power supply and insensitive to power consumption. Weak current firmware is suitable for battery-powered products that require higher power consumption.

After selecting the module and firmware, you can purchase module samples online.

The hardware engineer can enter the drawing board stage, and the related materials for hardware development can be viewed in the document center:

Data manual link: Zigbee module data manual

Module minimum schematic: Zigbee module minimal system schematic diagram

PCB data: Common module package library

Distribution Network Verification

After getting the module, users do n’t need to worry about writing code first. It is recommended to use the module debugging assistant (MCU simulation mode) provided by Tuya to connect with the Zigbee module first. When verifying the module, users can be familiar with The protocol interaction process will greatly improve the efficiency of development and debugging later.

Tuya module debugging assistant-MCU simulation mode. The assistant will simulate the MCU to automatically reply the module's correct protocol data. After the module is networked with a mobile phone, the DP data can be reported and issued. The following briefly introduces the main steps of the assistant and module distribution network operation. Before using it, you need to know the instructions of Tuya Module Debugging Assistant in advance. Users who use the assistant for the first time can read in advance: Module Debugging Assistant Instruction

step1. According to the minimum system schematic diagram, set up the module peripheral circuit, and simple test can directly fly the wire.

step2. Open the Tuya module debugging assistant in the development kit and import the debugging file. Protocol selection Wi-Fi universal protocol, MCU simulation mode.

step3. Connect the serial port of the module to the computer through the USB to TTL tool. The assistant selects the corresponding serial port and baud rate. Open the serial port and click Start. You will see that the module and the host computer automatically perform the initialization process protocol interaction.

Note: If no data is sent after power on, please check if the peripheral circuit of the module is correct.

step4. Click Reset Module, the module enters the network distribution mode. According to the status prompt, the App performs the corresponding network configuration operation. For the network configuration operation, you can read the instruction of the App.

Note: Before configuring the sub-device, the gateway needs to be connected to the Internet with Tuya Smart or Smart Life App before adding the Zigbee sub-device. For details, please refer to the document Zigbee Network Configuration Instructions and video Zigbee Gateway Network Configuration

Software Development

In the process of hardware debugging, the user saw that the module and the MCU have a series of serial protocol protocol interaction data. For the understanding of these data, please refer to the protocol document in the development kit.

The agreement is mainly divided into two parts: the basic agreement and the functional agreement. The basic protocol has nothing to do with the product. It is a common protocol of the module, including module initialization instructions and some extended function instructions. The function protocol part is mainly based on the command word of the report of the basic protocol, and has explained the DP data content format in detail. The complete content of the basic protocol, the document center is kept updated in real time, you can click the link to view: Tuya Zigbee module UART communication protocol

There are two ways for MCU to interface with Tuya module: transplant the MCU SDK or connect the protocol by yourself.

  • Self-docking agreement

    When MCU resources are limited or the MCU SDK is not suitable for porting, customers can choose to connect the serial port protocol by themselves.

  • Porting MCU SDK

    If the MCU resources are sufficient, it is generally recommended that users directly port the MCU SDK for efficient and convenient development. The MCU SDK in the development kit is a C-based protocol application code provided by Tuya, which can be directly added to the MCU project. The MCU SDK requires MCU hardware resources: 4K bytes of Flash; RAM is related to the length of the DP point data, about 100 bytes (if OTA function is required, it must be greater than 260 bytes); the number of function nesting levels is 9 levels. If users with insufficient resources can connect the protocol by themselves, the functions in the SDK package can still be used as a reference.

    MCU SDK Porting Tutorial: Overview of migrating Tuya's MCU SDK

Functional debugging

After porting the MCU SDK code development, you can use the Tuya module debugging assistant-module simulation mode to verify the correctness of the MCU code. The usage method is similar to the MCU simulation mode. In the simulation module mode, the assistant will automatically send the initialization data stream to verify that the MCU response is correct and give corresponding prompts for the incorrect data. After the initial interaction is passed, you can manually click to test other extended functions.

Note: Tuya module debugging assistant module simulation mode, without networking function, only used to verify the correctness of MCU serial protocol transmission and reception. After the test is completed, the MCU can be connected to the actual module and network.

Debugging common tool links:

Background log query entry: IoT Workbench-Operation Center. You can query related device background log data based on the device ID.

Tuya Online Support Portal: Tuya provides online support services. If the problem documents cannot be answered, you can Ask questions directly online, and the professional and technical team will answer your questions.

Last updated