Bluetooth: Path loss monitoring
The Path loss monitoring sample demonstrates how to evaluate Bluetooth® LE signal quality using the path loss monitoring feature. It consists of a Central and a Peripheral device. The Central continuously monitors the signal strength and classifies the connection quality using onboard LEDs.
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
|
|---|---|---|---|
PCA10156 |
|
||
PCA10175 |
|
||
PCA10095 |
|
||
PCA10056 |
|
To run this sample, you must use two compatible development kits, one programmed with the Central application, and the other with the Peripheral application.
Overview
This sample illustrates Bluetooth LE path loss monitoring by calculating the signal degradation between two connected devices.
The Central application scans for a Peripheral named path_loss_peripheral and connects to it.
After a successful connection, the Central measures path loss using the following formula:
path loss = TX Power - RSSI
The application defines the following three signal quality zones based on the path loss value:
Low path loss (strong signal) - LED0 is lit.
Medium path loss - LED1 is lit.
High path loss (weak signal) - LED2 is lit.
The Peripheral advertises its presence and accepts connections.
User interface
Central
LED0: Indicates Low path loss (good signal).
LED1: Indicates Medium path loss.
LED2: Indicates High path loss (weak signal).
No buttons are used.
Peripheral
No direct user interface.
The device advertises under the name path_loss_peripheral.
Configuration
See Configuring and building for information about how to permanently or temporarily change the configuration.
Additional configuration
Check and configure the following Kconfig options:
CONFIG_BT_CENTRAL- Enables the Bluetooth LE Central role (Central application).CONFIG_BT_PERIPHERAL- Enables the Bluetooth LE Peripheral role (Peripheral application).CONFIG_BT_DEVICE_NAME- Sets the advertising name of the Peripheral.CONFIG_BT_SCAN- Enables scanning for Bluetooth LE advertisements (Central only).CONFIG_BT_SCAN_FILTER_ENABLE- Enables name-based filtering for scan results (Central only).CONFIG_BT_PATH_LOSS_MONITORING- Enables the Bluetooth LE path loss monitoring feature on both devices.CONFIG_DK_LIBRARY- Enables the LEDs on the development kits.
Building and running
This sample can be found under samples/bluetooth/path_loss_monitoring in the nRF Connect SDK folder structure.
To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.
Note
When building repository applications in the SDK repositories, building with sysbuild is enabled by default.
If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.
When building this sample with Sysbuild for an SoC that has a network core, the IPC radio firmware is automatically applied to the build.
The IPC radio is one of the companion components in the nRF Connect SDK and allows to use the radio peripheral from another core in a multicore device.
If needed, you can modify the IPC radio configuration in the prj.conf source file in the sample’s sysbuild/ipc_radio directory.
Testing
After programming the sample to your development kit, complete the following steps to test it:
Program one DK with the
samples/bluetooth/path_loss_monitoring/centralcode.Program another DK with the
samples/bluetooth/path_loss_monitoring/peripheralcode.Power on both devices.
The Central will start scanning and connect automatically to the Peripheral.
Once connected, observe the LEDs on the Central to evaluate signal strength:
Bring the devices closer or move them farther apart to change the signal quality.
Optionally, place an obstruction between the devices to see how this affects signal quality.
Monitor the virtual serial ports for logs showing connection status and real-time path loss.
Sample output
The following output is logged from the Central device:
[00:00:01.000,000] <inf> central_unit: Starting path loss monitoring sample
[00:00:01.500,000] <inf> central_unit: Scanning for peripherals...
[00:00:03.020,000] <inf> central_unit: Found peripheral: FF:EE:DD:CC:BB:AA
[00:00:03.050,000] <inf> central_unit: Connection to FF:EE:DD:CC:BB:AA
[00:00:03.800,000] <inf> central_unit: Connected to FF:EE:DD:CC:BB:AA
[00:00:03.810,000] <inf> central_unit: Path loss monitoring enabled
[00:00:05.010,000] <inf> central_unit: Zone 0. Path loss: 30 dBm
[00:00:06.010,000] <inf> central_unit: Zone 1. Path loss: 45 dBm
[00:00:07.010,000] <inf> central_unit: Zone 2. Path loss: 63 dBm
Dependencies
This sample uses the following nRF Connect SDK libraries:
It uses the following Zephyr libraries:
include/zephyr/bluetooth/bluetooth.hinclude/zephyr/bluetooth/conn.hinclude/zephyr/bluetooth/uuid.hinclude/zephyr/bluetooth/addr.hinclude/zephyr/bluetooth/gap.hinclude/zephyr/logging/log.hinclude/zephyr/kernel.hinclude/bluetooth/scan.hinclude/dk_buttons_and_leds.h