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

Board target

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp

nRF54H20 DK

PCA10175

nrf54h20dk

nrf54h20dk/nrf54h20/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

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:

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:

  1. Program one DK with the samples/bluetooth/path_loss_monitoring/central code.

  2. Program another DK with the samples/bluetooth/path_loss_monitoring/peripheral code.

  3. Power on both devices.

  4. The Central will start scanning and connect automatically to the Peripheral.

  5. 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.

  6. 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.h

  • include/zephyr/bluetooth/conn.h

  • include/zephyr/bluetooth/uuid.h

  • include/zephyr/bluetooth/addr.h

  • include/zephyr/bluetooth/gap.h

  • include/zephyr/logging/log.h

  • include/zephyr/kernel.h

  • include/bluetooth/scan.h

  • include/dk_buttons_and_leds.h