Is this page helpful?YesNo
Last Updated on : 2021-06-07 06:30:25download
Tuya provides a complete set of modules, apps, and cloud services for Bluetooth mesh development. The Bluetooth mesh general firmware provided by Tuya is completed with the Bluetooth mesh protocol, and the MCU can be connected to the network when the serial protocol is implemented. After you implement serial protocol interaction and bind the device to the app, the Bluetooth mesh device will automatically form a mesh network without additional operation on the MCU.
On July 19, 2017, the Bluetooth Special Interest Group (SIG) announced that Bluetooth technology began to fully support mesh networks. The brand-new mesh technology supports many-to-many transmission, improving the communication efficiency of building a wide network coverage. Mesh technology applies better to building automation, wireless sensor networks, and more applications, providing a safe, reliable, and stable environment for tens of thousands of devices for information interaction.
The Tuya Bluetooth mesh development solution provides easy integration and convenient SDK migration. The communication schematic diagram is as follows.
The communication process without a Bluetooth mesh gateway:
The communication process with a Bluetooth mesh gateway:
This section describes the product creation process using the Bluetooth mesh communication solution. For more information, see MCU Connection Solution.
Log in to the IoT Platform and create a product. Select the product category as needed, and select Bluetooth Mesh(SIG) for protocol type.
After finishing creation, you can select the functions and panel as needed, and download the MCU development documents from the Hardware Development page accordingly.
Select a module and generate firmware.
The platform recommends common models when you create a product. After selecting the module and firmware, you can purchase the module sample online.
The hardware engineer will proceed with the board layout design. The documentation related to hardware development is as follows:
Note: If the power is supplied by batteries when the supply voltage is lower than normal working voltage, flash operation inside the chip might have an error, thus firmware or user data might be modified abnormally. When the MCU detects that battery voltage is too low:
- Cut off the working power supply of the module.
- Disable the broadcast and system timer, and let the chip enter deep sleep mode to stop working. For example, if the minimum operating voltage of the module is 1.8V, when the voltage is less than 2.0V, the MCU powers off the module.
Tuya Bluetooth mesh serial protocol architecture is as follows.
Note: After receiving the module, make sure the module works properly before encoding. In the MCU simulation mode, the debugging assistant simulates the MCU to automatically respond to the module with the correct protocol data. After you pair the module with the mobile phone, you can test DP data reporting and sending. You can get familiar with the protocol interaction process while verifying the module, which will enhance development debugging efficiency in subsequent stages. The connection between the simulated MCU and the Tuya module is as follows:
This section describes the steps of operating the assistant and pairing the module. For more information, see Module Debugging Assistant.
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.
Open the debugging assistant in the development documents, and import the debugging file. Select the Bluetooth mesh general protocol and MCU simulation mode.
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, and the module will automatically proceed with initial protocol interaction with the host.
Note: The Bluetooth mesh 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.
Click Reset in the Distribution Network Function area and the module enters network pairing mode. The module will disconnect Bluetooth, remove Bluetooth binding, clear cache, and then reboot.
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 a basic protocol and function protocol.
The basic protocol is product-neutral and shared by the modules. It consists of module initial commands and certain extension function commands.
The function protocol works to report and send commands based on the basic protocol and specifies the DP data format. For the full content of the basic protocol, see Bluetooth Mesh General Serial Protocol.
You can connect to the Tuya module protocol by either migrating MCU SDK or connecting the protocol by yourself. MCU SDK in the development documents is the protocol application code in C language, and it can be directly imported to the MCU project.
Migrate MCU SDK
Connect the protocol by yourself If the MCU resource is limited or migrating MCU SDK is inapplicable, you can connect the protocol by yourself.
After migrating MCU SDK, you need to use the module debugging assistant in module simulation mode to verify the MCU code. In the module simulation mode, the assistant automatically sends the initial data flow to verify whether the MCU response is correct, and sends 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 debugging of pairing. The connection schematic diagram in module simulation mode is as follows.
After the assistant verifies the code, connect the MCU to the module, and pair the module 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:
Is this page helpful?YesNo
Is this page helpful?YesNo