Bluetooth: Mesh sensor server

The Bluetooth Mesh sensor server sample demonstrates how to set up a basic Mesh sensor server model application that provides sensor data to one Mesh sensor client model. Four different sensor types are used to showcase different ways for the server to publish data. In addition, the samples demonstrate usage of both single-channel sensor types and sensor series types.

Note

This sample must be paired with Bluetooth: Mesh sensor client to show any functionality. The server provides the sensor data used by the client.

Overview

This sample is split into the following source files:

  • A main.c file to handle initialization.

  • One additional file for handling Mesh models, model_handler.c.

The following Mesh sensor types are used in this sample:

Moreover, the on-chip TEMP_NRF5 temperature sensor is used.

Provisioning

The provisioning is handled by the Bluetooth Mesh provisioning handler for Nordic DKs. Use nRF Mesh mobile app for provisioning and configuring of models supported by the sample.

Models

The following table shows the Mesh sensor server composition data for this sample:

Element 1

Config Server

Health Server

Sensor Server

The models are used for the following purposes:

  • Config Server allows configurator devices to configure the node remotely.

  • Health Server provides attention callbacks that are used during provisioning to call your attention to the device. These callbacks trigger blinking of the LEDs.

  • Mesh sensor server provides sensor data to one or more Mesh sensor client(s).

The model handling is implemented in src/model_handler.c, which uses the TEMP_NRF5 temperature sensor, and the DK Button and LEDs library to detect button presses.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

The sample also requires a smartphone with Nordic Semiconductor’s nRF Mesh mobile app installed in one of the following versions:

Additionally, the sample requires the Bluetooth: Mesh sensor client sample application, programmed on a separate device and configured according to the Mesh sensor client sample’s testing guide.

User interface

Buttons:

Can be used to input the OOB authentication value during provisioning. All buttons have the same functionality during the provisioning procedure.

Button 1:

Simulate presence detected (after the provisioning procedure is finished).

Building and running

This sample can be found under samples/bluetooth/mesh/sensor_server in the nRF Connect SDK folder structure.

See Building and programming a sample application for information about how to build and program the application.

Testing

Note

The Mesh sensor server sample cannot demonstrate any functionality on its own, and needs a device with the Bluetooth: Mesh sensor client sample running in the same Mesh network. Before testing the Mesh sensor server, go through the Mesh sensor client’s testing guide with a different board.

After programming the sample to your board, you can test it by using a smartphone with Nordic Semiconductor’s nRF Mesh app installed. Testing consists of provisioning the device and configuring it for communication with the mesh models.

Provisioning the device

The provisioning assigns an address range to the device, and adds it to the mesh network. Complete the following steps in the nRF Mesh app:

  1. Tap Add node to start scanning for unprovisioned mesh devices.

  2. Select the Mesh Sensor Server device to connect to it.

  3. Tap Identify and then Provision to provision the device.

  4. When prompted, select an OOB method and follow the instructions in the app.

Once the provisioning is complete, the app returns to the Network screen.

Configuring models

Complete the following steps in the nRF Mesh app to configure models:

  1. On the Network screen, tap the Mesh Sensor Server node. Basic information about the mesh node and its configuration is displayed.

  2. In the Mesh node view, expand the element. It contains the list of models in the first and only element of the node.

  3. Tap Sensor Server to see the model’s configuration.

  4. Bind the model to application keys to make it open for communication:

    1. Tap BIND KEY at the top of the screen.

    2. Select Application Key 1 from the list.

  5. Set the publishing parameters:

    1. Tap SET PUBLICATION.

    2. Tap Publish Address.

    3. Select Groups from the drop-down menu.

    4. Select an existing group or create a new one.

      Note

      The sensor client must subscribe to the same group.

    5. Tap OK.

    6. Select a publishing period by using the Interval slider.

    7. Set the Retransmit Count to zero (Disabled) to avoid duplicate logging in the sensor client’s UART terminal.

    8. Tap the confirmation button at the bottom right corner of the app to save the parameters.

  6. Set subscription parameters:

    1. Tap SUBSCRIBE.

    2. Select an existing group or create a new one.

      Note

      The sensor client must publish to the same group.

    3. Tap OK.

  7. Double-tap the back arrow button at the top left corner of the app to get back to the main application screen.

The sensor server model is now configured and able to send data to the client.

Note

To enable server configuration by a client, an application key must be bound to the sensor setup server. This functionality must also be programmed in the Sensor Client device.

Dependencies

This sample uses the following nRF Connect SDK libraries:

In addition, it uses the following Zephyr libraries: