STM32WB BLE MESH Sensor Model

Revision as of 15:28, 3 August 2021 by Registered User (→‎Code Modification)

1. Technical Description

This project demonstrates STM32WB application capabilities using BLE-Mesh solution and with a sensor module and using specific Sensor Client commands.

The goal of the project is to send sensor data from the Sensor Server to the Sensor Client on Sensor Client request.

To realize this project, we use two Discovery Kits including temperature and time of flight sensors.

One board will implement a BLE Mesh Sensor Server Node, and the second board a Sensor Client Node. A short push on Sensor Client User Button 1 (B1) send a Get Temperature request to the Sensor Server, a long push will send a Get Distance request. The Server will answer to the Client and the required data will be displayed on Client logs.

2. Demonstration Setup

2.1. Device Requirement

Required material to setup the demonstration is the following:

  • 2 Discovery Kit : As temperature sensing boards
  • 1 Smartphone with Android or iOS

Click on Component Hyperlink to see resellers.

2.2. Software patch

  • STM32Cube_FW_WB_V1.12.0 package include some Discovery Kit projects: STM32Cube_FW_WB_V1.12.0\Projects\STM32WB5MM-DK\Applications\BLE\
  • A patch is available to include the Sensor Server/Client project and his dependencies to the Firmware package v1.12.0: STM32Cube_FW_WB_BLEMeshSensorClientServer_DEMO_V1.12.0.exe
  • Launch this .exe file and follow the instructions. In the Select Destination Location step, select the path to your Firmware Package.

Note: be careful to remove the \New Folder added automatically at the end of the path you selected

The Project example will be located at: __INTERNAL__Projects\STM32WB5MG-DK\Applications\BLE\ BLE_WB5M_Mesh_Sensor_Example

2.3. Code Modification

Server/Client setup:
Modify the mesh_cfg_usr.h file in order to chose between the Client or Server configuration:

  • Server:
/* Enable Sensor Model Server or Sensor Model Client */
//#define ENABLE_SENSOR_MODEL_SERVER                                        (1)

#define ENABLE_SENSOR_MODEL_CLIENT                                           (1)
  • Client:
/* Enable Sensor Model Server or Sensor Model Client */
//#define ENABLE_SENSOR_MODEL_SERVER                                        (1)

#define ENABLE_SENSOR_MODEL_CLIENT                                           (1)

After each modification, rebuild the project and flash the corresponding board.

3. Sensor Model Code Description

3.1. Node Setup

3.2. Sensor Definition

3.3. Sensor Initialization (Server side)

3.4. SENSOR_GET Request (Client Side)

3.5. Sensor Data reading (Server Side)

3.6. Sensor Data Reception (Client Side)

4. Demonstration Handle