Last Updated on : 2024-07-05 10:01:35download
In terms of Bluetooth mesh development, Tuya provides one-stop services including network modules, mobile apps, and cloud services, to help you implement an internet connection for your current product.
The Bluetooth mesh generic firmware provided by Tuya has been integrated with the Bluetooth mesh protocol. After integration with the protocol, the MCU can implement the network connection. You only need to implement serial communication between the MCU and the module and bind the device with the app. The Bluetooth mesh devices will automatically form a mesh network without any additional operations on the MCU.
On July 19, 2017, the Bluetooth Special Interest Group (SIG) announced to provide Bluetooth mesh technologies to enable mesh networking. The new mesh technology can support many-to-many transmission between devices, thus improving communication efficiency by building large-scale network coverage.
Mesh technology adapts to scenarios such as building automation and wireless sensor networks, allowing tens of thousands of devices to exchange data in a safe, reliable, and stable environment.
Benefits
Limitations
Application scenarios
Tuya Bluetooth mesh development solution enables simple integration and convenient SDK porting. The following two figures show how the communication works.
Schematic diagram of Bluetooth mesh communication without gateway
Schematic diagram of Bluetooth mesh communication with gateway
This section describes how to create a product on the Tuya Developer Platform. For more information, see the MCU SDK Development.
Log in to the Tuya Developer Platform and create a product. Select the desired product category. Choose Bluetooth Mesh(SIG) for Protocol.
After you create a product, you can configure the functions and panel based on your requirements. Then, click the Hardware Development tab and download the MCU SDK accordingly.
Select the desired module and build firmware.
The platform recommends popular modules when you create a product. After you select the module and build firmware, you can purchase the sample module on the platform.
During the hardware development, you can proceed with the board layout design. For more information about hardware development, see related documents in Tuya’s documentation center.
When batteries are used as power supply and the supply voltage is below the operating voltage, operations on the flash memory of the module might cause errors in firmware or user data. When the MCU detects that the battery voltage is too low, you can take the following steps:
Background information
The following figure shows how Tuya’s Bluetooth mesh module communicates with an MCU.
Things to note
You can check whether your received module can work as expected and start encoding. Tuya’s Module Debugging Assistant (in MCU simulation mode) will simulate the MCU to automatically reply the correct protocol data to the module. After the module is paired using a mobile phone, you can test the reporting and sending of DP data. While verifying the module, you can get familiar with the protocol interaction process, which will greatly improve the efficiency of later development and debugging.
The following figure shows the connection method of the Module Debugging Assistant in MCU simulation mode.
Procedure
The following steps describe how to pair the module and use the Module Debugging Assistant. For more information, see Module Debugging Assistant.
Set up the peripheral circuit according to the schematic for a minimum system.
Open Tuya’s Module Debugging Assistant in the development kit, import the debugging file, and then select Bluetooth mesh generic protocol and MCU simulation mode.
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.
The module constantly sends heartbeats to the MCU after power-on. It will start initialization on receiving the correct response from the MCU. If the module does not send data upon powering on, check whether the peripheral circuit of the module works as expected.
In the section of Distribution Network Function, reset the module to enter pairing mode. The module will disconnect and unbind from Bluetooth, clear cache information, and then restart.
Protocol description
In the previous testing step, the left screen of Tuya’s debugging assistant shows you the data communication between the MCU and the module. For more information about communication logic, see the protocol documentation included in the development document. The protocol consists of the basic protocol and the function protocol.
The basic protocol is product-neutral and shared by the modules. It consists of commands for module initialization and extended functions.
The function protocol works to report and send commands based on the basic protocol and specifies the DP data format. For more information, see Bluetooth Mesh Serial Communication Protocol.
Integration method
You can interface with the Tuya module protocol by porting the MCU SDK or interfacing with the protocol yourself. The MCU SDK is written in C language. You can directly import it to your project.
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 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.
The following figure shows the connection in module simulation mode.
After the code is verified, you can pair the module with the app and test DP data communication. You can check the device logs as shown below:
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback