Skip to content

Gary-zzy/BLE-Sensor-Server

Repository files navigation

Bluetooth Mesh: Sensor

The Bluetooth® Mesh sensor sample demonstrates how to set up a basic mesh Sensor Server model application that provides sensor data to one :ref:`bt_mesh_sensor_cli_readme` model. Eight different sensor types are used to showcase different ways for the server to publish data. In addition, the samples demonstrate usage of both :ref:`single-channel sensor types and sensor series types <bt_mesh_sensor_types_channels>`, as well as how to add and write to a sensor setting.

Note

This sample must be paired with the :ref:`bluetooth_mesh_sensor_client` sample to show any functionality. The mesh sensor provides the sensor data used by the observer.

This sample demonstrates how to implement the following :ref:`ug_bt_mesh_nlc`:

  • Ambient Light Sensor NLC Profile
  • Occupancy Sensor NLC Profile

The sample supports the following development kits:

.. table-from-sample-yaml::

For provisioning and configuring of the mesh model instances, the sample requires a smartphone with Nordic Semiconductor's nRF Mesh mobile app installed in one of the following versions:

Additionally, the sample requires the :ref:`bluetooth_mesh_sensor_client` sample application. The application needs to be programmed on a separate device, and configured according to the sensor observer sample's :ref:`testing guide <bluetooth_mesh_sensor_server_testing>`.

The following Bluetooth Mesh sensor types, and their settings, are used in this sample:

Note

These values can be requested through shell commands by the :ref:`bluetooth_mesh_sensor_client`.

Moreover, the on-chip TEMP_NRF5 temperature sensor is used for the nRF52 series, and the BME680 temperature sensor for Thingy:53.

Note

When running this sample on Thingy:53, some functionality will not be available as the device only has two buttons. The two buttons on Thingy:53 will be used for the ambient light sensor and presence detected sensor functionality as described for Button 1 and Button 2 in this documentation. Button 2 can be accessed by removing the top part of the casing.

The provisioning is handled by the :ref:`bt_mesh_dk_prov`. It supports four types of out-of-band (OOB) authentication methods, and uses the Hardware Information driver to generate a deterministic UUID to uniquely represent the device.

Use `nRF Mesh mobile app`_ for provisioning and configuring of models supported by the sample.

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

Element 1 Element 2 Element 3 Element 4 Element 5
Config Server Sensor Server Sensor Server Sensor Server Sensor Server
Health Server Sensor Setup Server Sensor Setup Server Sensor Setup Server Sensor Setup Server
Sensor Server        
Sensor Setup 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.
  • Sensor Server instances provide sensor data to one or more :ref:`mesh sensor observers <bt_mesh_sensor_cli_readme>`.
  • Sensor Setup Server instances are used for configuration of the corresponding Sensor Server instances.

The model handling is implemented in :file:`src/model_handler.c`. It uses the TEMP_NRF5 or BME680 temperature sensor depending on the platform.

The sample has a descriptor related to the :c:var:`bt_mesh_sensor_present_dev_op_temp` sensor, which specifies tolerance values for the TEMP_NRF5 temperature sensor calculated based on the `nRF52832 Temperature Sensor Electrical Specification`_. The descriptor also specifies the temperature sensor's sampling type, which is :c:var:`BT_MESH_SENSOR_SAMPLING_INSTANTANEOUS`.

The :ref:`dk_buttons_and_leds_readme` library is used to detect button presses.

The :ref:`Zephyr settings API <zephyr:settings_api>` is used to persistently store the following settings given that :kconfig:option:`CONFIG_BT_SETTING` is enabled:

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

Once the provisioning procedure has completed, the buttons will have the following functionality:

.. tabs::

   .. group-tab:: nRF21 and nRF52 DKs

      Button 1:
        Simulates different ambient light sensor values.
        These dummy values represent raw values coming from an ambient light sensor.

      Button 2:
        Simulates presence detected.
        For how long the button has to be pressed before the presence is detected depends on the motion threshold.
        The motion threshold has five steps from 0 % (representing 0 seconds) to 100 % (representing 10 seconds) separated by 25 %-steps.

      Button 3:
        Simulates motion sensed.

      Button 4:
        Simulates different people count sensor values.
        These dummy values represent raw values coming from a people count sensor.

   .. group-tab:: nRF54 DKs

      Button 0:
        Simulates different ambient light sensor values.
        These dummy values represent raw values coming from an ambient light sensor.

      Button 1:
        Simulates presence detected.
        For how long the button has to be pressed before the presence is detected depends on the motion threshold.
        The motion threshold has five steps from 0 % (representing 0 seconds) to 100 % (representing 10 seconds) separated by 25 %-steps.

      Button 2:
        Simulates motion sensed.

      Button 3:
        Simulates different people count sensor values.
        These dummy values represent raw values coming from a people count sensor.

|config|

|nrf5340_mesh_sample_note|

This sample is split into the following source files:

Note

The Bluetooth Mesh sensor sample cannot demonstrate any functionality on its own, and needs a device with the :ref:`bluetooth_mesh_sensor_client` sample running in the same mesh network. Before testing the sensor sample, go through the sensor observer sample's :ref:`testing guide <bluetooth_mesh_sensor_client_testing>` with a different development kit.

After programming the sample to your development kit, you can test it by using a smartphone with `nRF Mesh mobile app`_ installed. Testing consists of provisioning the device, and configuring it for communication with the mesh models.

Provisioning the device

Configuring models

See :ref:`ug_bt_mesh_model_config_app` for details on how to configure the mesh models with the nRF Mesh mobile app.

Configure Sensor Server model on each element on the Mesh Sensor node:

  • Bind the model to Application Key 1.
  • Set the publication parameters:
    • Destination/publish address: Select an existing group or create a new one, but make sure that the Sensor Client subscribes to the same group.
    • Retransmit count: Set the count to zero (Disabled), to avoid duplicate logging in the :ref:`bt_mesh_sensor_cli_readme`'s UART terminal.
  • Set the subscription parameters: Select an existing group or create a new one, but make sure that the Sensor Client publishes to the same group.

The Sensor Server models are now configured and able to send data to the Sensor Client.

Configure the corresponding Sensor Setup Server model on each element on the Mesh Sensor node:

  • Bind the model to Application Key 1.
  • Set the subscription parameters: Select an existing group or create a new one, but make sure that the Sensor Client publishes to the same group.

The Sensor Setup Server models are now configured and able to receive sensor setting messages from the Sensor Client.

Note

To enable Sensor Server configuration by a Sensor Client, an application key must be bound to the Sensor Setup Server. This functionality must also be programmed in the :ref:`bt_mesh_sensor_cli_readme` device.

This sample uses the following |NCS| libraries:

In addition, it uses the following Zephyr libraries:

The sample also uses the following secure firmware component:

About

sensor server for personalized sensor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published