Wi-Fi Module MCU Development Overview

Introduction

The Wi-Fi universal solution is one of the mainstream MCU interconnection solutions. The communication schematic diagram is as follows. Users only need to use the Tuya Wi-Fi 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, the Wi-Fi module is connected to the cloud through a router, requiring no gateway, convenient operation data, fast transmission speed, and better user experience.

This article is mainly an overview of the development process of Tuya Wi-Fi 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 Wi-Fi 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.

Some product categories have extended options for power consumption. For normal power supply products, we can choose standard power consumption. Battery-powered products can choose low power consumption.

Note: Power consumption selection will be related to the recommendation of subsequent modules and firmware.

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. Here is a brief introduction to the most commonly used Wi-Fi modules in the Wi-Fi universal solution.Wi-Fi modules are are divided into 1, 2, and 3 series according to the package. Common models are:

  • WR1 / WBR1 / WBR1D, etc

1 series, common model, slightly larger package, generally optional onboard or external antenna, external antenna version model is "module model-IPEX".

  • WR2 / WBR2 / WBR2D, etc

2 series, plug-in packaging, less use, product space volume requirements for use.

  • WR3 / WBR3 / WBR3D, etc

The volume of the 3 series is slightly smaller than that of the 1 series. The common package in the market is compatible with similar package module. It is also one of the most commonly used module models.

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: Wi-Fi module data manual

Module minimum schematic: Wi-Fi module minimal system schematic diagram PCB data: Common module package library

Note: Wi-Fi universal module working average current is within 100mA, but the peak current will reach more than 400mA (continued us level), there must be a margin when designing the power supply!

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 Wi-Fi 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: The Wi-Fi module will continuously send heartbeat packets upon power-on. After receiving the correct response, it will interact with subsequent initialization protocols. 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. The module supports two modes of network configuration: EZ and AP mode (the difference between EZ mode and AP mode). The reset button will switch the network configuration 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. Attach a demo video of the network distribution in two modes:

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 Cloud Universal Serial Port Access 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. The detailed explanation of serial port protocol can refer to: Protocol Analysis

  • 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.

FAQ collection for open platform: develop common problems, understand them in advance, and avoid stepping into the pit.

Appendix

Video Tutorial

Using Tuya MCU Scheme to Create Products

Last updated