This example demonstrates how to use the Sensor model. It implements an emulated Motion Sensed sensor and shows how such a sensor can be used and controlled.
The example is composed of the following minor examples:
For more information about the Sensor Cadence state, see Bluetooth mesh model specification, section 4.1.3.
Table of contents
You need at least two compatible development kits for this example:
Additionally, you need one of the following for provisioning:
See Compatibility for information about the compatible development kits.
Depending on the provisioning method:
You can find the source code of this example in the following folder: <InstallFolder>/examples/sensor
RTT input | DK Button | Effect |
---|---|---|
1 | Button 1 | The mocked sensor value is decreased by 1%. |
2 | Button 2 | The mocked sensor value is decreased by 10%. |
3 | Button 3 | The mocked sensor value is increased by 1%. |
4 | Button 4 | The mocked sensor value is increased by 10%. |
5 | - | All Bluetooth mesh data is erased and the device is reset. |
RTT input | DK Button | Effect |
---|---|---|
1 | Button 1 | Send a descriptor get message for all properties. |
2 | Button 2 | Send a descriptor get message for the Motion Sensed property. |
3 | Button 3 | Send a cadence get message for the Motion Sensed property. |
4 | Button 4 | Send an acknowledged cadence set message for the Motion Sensed property. |
5 | - | Send an unacknowledged cadence set message for the Motion Sensed property. |
6 | - | Send a settings get message for the Motion Sensed property. |
7 | - | Send a status get message for all properties. |
8 | - | Send a status get message for the Motion Sensed property. |
9 | - | Switches the client instance to be used for sending messages. |
To test the sensor example, build the examples by following the instructions in Building the Bluetooth mesh stack.
After building is complete, use one of the following methods, depending on the preferred provisioning approach:
See provisioner example testing section for detailed steps required to provision and configure the boards using the static provisioner.
See Evaluating examples using the nRF Mesh mobile application for detailed steps required to provision and configure the boards using the nRF Mesh mobile app.
The following naming convention is used in the app:
nRF5x Mesh Sensor Setup Server
.nRF5x Mesh Sensor Client
.The following model instances must be configured in the app for this example:
nRF5x Mesh Sensor Setup Server
server boards: Sensor Setup Server, Sensor Server.nRF5x Mesh Sensor Client
client board: Sensor Client.When setting publication with nRF Mesh mobile app, use the following procedure specific to this example:
nRF5x Mesh Sensor Setup Server
, in the publication section of the Sensor Serverc model instance menu, tap Set Publication.nRF5x Mesh Sensor Client
board.Once the provisioning with the mobile app is complete, you can start interacting with the boards.
Once the provisioning and the configuration of the client node and of at least one of the server nodes are complete, you can start interacting with the examples using buttons or RTT, or both.
The publication behavior of the Sensor server depends on the following parameters:
Disabled
.When the Publish Period of the Sensor Server model is set to zero, all button presses on the server will result in the sensor status message publications. Use the RTT Viewer to observe the incoming sensor status messages on the client and to observe the output of the server.
You can change the publication parameters to see how this will affect the publication behavior.
Field | Value |
---|---|
fast_period_exponent | 7 (representing 2^7 ) |
trigger_type | 0 |
trigger_delta_down | 1 |
trigger_delta_up | 1 |
min_interval_exponent | 1 |
fast_cadence_low | 0 |
fast_cadence_high | 49 (31 in hex) |
fast_cadence_high
value is higher than the fast_cadence_low
value, so Motion Sensed values in the closed interval of [fast_cadence_low
(0
), fast_cadence_high
(49
)] will cause the server's sensor publication period to be the server's Publish Period divided by 2^n
, where n
is the fast_period_exponent
(that is, 7
). This fast period is constrained to a minimum interval by min_interval
.20
. At the next periodic publication time, the server will find a Motion Sensed value of 20
. As the sensor value is within the fast cadence region, the server will begin to publish on a period of 60 sec / 2^7 = 0.4687 sec
. The client receives information about two messages per second if the motion sensor value remains between 0
and 49
.50
or higher. When this value is first published by the periodic publication on the server, the periodic publication period will be set to 60 seconds (the configured Publish Period for the server). As long as the server's publications find Motion Sensed values of at least 50
, the client receives one message per minute.