Contact Us
Log In

Wi-Fi Common Solution

Last Updated on : 2022-03-29 03:53:21download

Wi-Fi general solution is one of the major MCU connection solutions. Connect the MCU to the Wi-Fi module through the serial port to enable device network access. Tuya provides complete development services from modules, apps to cloud services.

Connection process

Compared to other communication solutions, the Wi-Fi module delivers a better user experience. It can directly connect to the cloud through a router without the gateway, which ensures easier data operation and faster data transmission.

The communication diagram of Wi-Fi general module connection is as follows:

Wi-Fi Common Solution

Development process

Step 1: Product creation

You can find the specific description of creating products in MCU Connection Solution. Refer to the section of Product creation.

Log in to the IoT console and create a product. Select the desired product, and select Wi-Fi for net pairing mode. After finishing creation, you select the functions, panel, module, and firmware based on your product, and download the MCU development documents accordingly. For certain product categories, a power type is an option. You select the standard power for products powered from mains electricity. For battery-powered products, low power is recommended.

Note: Power type determines the subsequent selection of modules and firmware.

Wi-Fi Common Solution

The platform recommends the common module models when you create a product. The most used Wi-Fi modules for Wi-Fi general solutions are described as follows. According to the packaging types, the Wi-Fi module is classified into three series, namely series one, two, and three. The common models are as follows:

  • The series one module, such as WR1, WBR1, and WBR1D, are the popular models. They use relatively large packages and allow on-board or external antenna. The model of the external antenna board is named “module model – IPEX”.

  • The series two modules, such as WR2, WBR2, and WBR2D, use a through-hole mounting scheme. If your product has space requirements, series two modules are recommended.

  • The series three modules, such as WR3, WBR3, and WBR3D, are smaller than series one, and use the common packages. As one of the most commonly used models, they are compatible with and can substitute modules of similar packages.

    Wi-Fi Common Solution

After selecting the module and firmware, you can purchase the module sample online. The hardware engineer will proceed with the board layout design. See the documentation related to hardware development in the documentation center.

  • Datasheet: TYWE1S Module Datasheet

  • Schematic diagram of the minimum module: TYWE1S Module

    Note: The average working electric current of Wi-Fi common modules is within 100mA and the peak electric current reaches over 400mA (sustained current in microseconds). Take the electric allowance into consideration during power design.

Step 2: Network configuration testing

When receiving the module, it is suggested that, before start coding, you run the provided module debugging assistant, and connect the Wi-Fi module in MCU simulation mode to check if the module can work properly. Meanwhile, you can get familiar with the protocol interaction process, which will help you to proceed with development debugging.

Wi-Fi Common Solution

In the MCU simulation mode, the debugging assistant simulates the MCU to automatically respond to the module with the correct protocol data. After you configure the network through the mobile phone, you can test DP data reporting and sending. The procedure of operating the assistant and module network configuration is as follows. Before the operation, you need to learn about the operation instruction of the Tuya module debugging assistant. For beginners, you can refer to Module Debugging Assistant Instruction.

  1. Based on the schematic diagram of the minimum system, you build the peripheral circuit of the module and jump the wire directly in case of simple testing.

  2. Open the debugging assistant in the development documents and import the debugging file. Select the Wi-Fi general protocol and MCU simulation mode.

  3. Connect the module serial port to the computer through a USB-to-TTL adapter and select the corresponding serial port and Baud in the assistant. After you open the serial port and click Start, you will see the initial protocol interaction between the module and the host.

    Note: Wi-Fi module will constantly send heartbeat packets after power on. When receiving the correct response, it will proceed with the initial protocol interaction. If the module does not send data after power on, check if the peripheral circuit of the module is correct.

  4. Click the Reset Module, and the module enters the network configuration mode. The module supports two network configuration modes, EZ and AP (The difference between EZ and AP modes). When you click Reset Module, the mode will be switched. Configure the network on the app according to the status. Refer to the app operation instruction for network configuration operation.

    Wi-Fi Common Solution

Step 3: Software development

During hardware debugging, you will see a sequence of serial port protocol interaction data between the module and MCU. To understand this data, refer to the protocol documentation in the development documents.

The protocol consists of the basic protocol and function protocol.

  • The basic protocol is product-neutral and shared by the modules. It consists of a module initial command and certain extension function command. The basic protocol is updated in real-time in the documentation center. See Tuya Cloud Universal Serial Port Access Protocol.

  • The function protocol works to report and send commands based on the basic protocol and specifies the DP data format.

There are two methods to connect the MCU to the Tuya module protocol, migrating MCU SDK, or connecting the protocol by yourself.

  • Connect the protocol by yourself

    If the MCU resource is limited or migrating the MCU SDK is inapplicable, you can connect the protocol by yourself. For the description of the serial port protocol, see Wi-Fi Module General Protocol Parsing.

  • Migrate MCU SDK

    If the MCU resource is sufficient, it is recommended to directly migrate MCU SDK, which facilitates the development process. MCU SDK in the development documents is the protocol application code in C language, and it can be directly imported to the MCU project. MCU SDK requirements for MCU hardware resources are 4 KB Flash and about 100 bytes of RAM. RAM is related to DP data length. For example, the OTA function takes more than 260 bytes. A 9-level nested function is adopted. If the resource is limited, you can connect the protocol by yourself. The function in the SDK package can act as references.

MCU SDK migration tutorial: Overview of migrating Tuya’s MCU SDK

Step 4: Protocol verification

After migrating MCU SDK, you can use the module debugging assistant in module simulation mode to verify the MCU code. The operation is similar to the MCU simulation mode. In the module simulation mode, the assistant automatically sends the initial data flow to verify whether the MCU response is correct, and send prompts for data error. After the initial interaction, you can test other extension functions.

Note: The module simulation mode only verifies the MCU serial port protocol, and does not support networking. After finishing the test, connect the MCU to the actual module and proceed with joint network configuration debugging.

Wi-Fi Common Solution

Wi-Fi Common Solution

Step 5: Joint debugging

After the assistant verifies the code, connect the MCU to the module, and configure the network on the app. You will enter function joint debugging. Joint debugging is used to test whether the DPs reporting and sending work properly. The links of useful tools adopted in the debugging are as follows:

Query the background log: Log in to the IoT console and enter Operation center. Query device background logs according to its device ID.

Online support center: Tuya provides online services. If the documentation cannot solve your problems, raise your questions online and our technical team will help you troubleshoot problems.


Download routine

This section contains the following topics to help you quickly understand related concepts and how-to guides: