|
| 1 | +.. _bluetooth_path_loss_monitoring: |
| 2 | + |
| 3 | +Bluetooth: Path loss monitoring |
| 4 | +############################### |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The Path loss monitoring sample demonstrates how to evaluate Bluetooth® LE signal quality using the path loss monitoring feature. |
| 11 | +It consists of a Central and a Peripheral device. |
| 12 | +The Central continuously monitors the signal strength and classifies the connection quality using onboard LEDs. |
| 13 | + |
| 14 | +Requirements |
| 15 | +************ |
| 16 | + |
| 17 | +The sample supports the following development kits: |
| 18 | + |
| 19 | +.. table-from-sample-yaml:: |
| 20 | + |
| 21 | +To run this sample, you must use two compatible development kits, one programmed with the Central application, and the other with the Peripheral application. |
| 22 | + |
| 23 | +Overview |
| 24 | +******** |
| 25 | + |
| 26 | +This sample illustrates Bluetooth LE path loss monitoring by calculating the signal degradation between two connected devices. |
| 27 | +The Central application scans for a Peripheral named ``path_loss_peripheral`` and connects to it. |
| 28 | +After a successful connection, the Central measures path loss using the following formula: |
| 29 | + |
| 30 | +.. code-block:: none |
| 31 | +
|
| 32 | + path loss = TX Power - RSSI |
| 33 | +
|
| 34 | +The application defines the following three signal quality zones based on the path loss value: |
| 35 | + |
| 36 | +* Low path loss (strong signal) - **LED0** is lit. |
| 37 | +* Medium path loss - **LED1** is lit. |
| 38 | +* High path loss (weak signal) - **LED2** is lit. |
| 39 | + |
| 40 | +The Peripheral advertises its presence and accepts connections. |
| 41 | + |
| 42 | +User interface |
| 43 | +************** |
| 44 | + |
| 45 | +Central |
| 46 | +======= |
| 47 | + |
| 48 | +* **LED0:** Indicates **Low** path loss (good signal). |
| 49 | +* **LED1:** Indicates **Medium** path loss. |
| 50 | +* **LED2:** Indicates **High** path loss (weak signal). |
| 51 | + |
| 52 | +No buttons are used. |
| 53 | + |
| 54 | +Peripheral |
| 55 | +========== |
| 56 | + |
| 57 | +No direct user interface. |
| 58 | +The device advertises under the name ``path_loss_peripheral``. |
| 59 | + |
| 60 | +Configuration |
| 61 | +************* |
| 62 | + |
| 63 | +|config| |
| 64 | + |
| 65 | +Additional configuration |
| 66 | +======================== |
| 67 | + |
| 68 | +Check and configure the following Kconfig options: |
| 69 | + |
| 70 | +* :kconfig:option:`CONFIG_BT_CENTRAL` - Enables the Bluetooth LE Central role (Central application). |
| 71 | +* :kconfig:option:`CONFIG_BT_PERIPHERAL` - Enables the Bluetooth LE Peripheral role (Peripheral application). |
| 72 | +* :kconfig:option:`CONFIG_BT_DEVICE_NAME` - Sets the advertising name of the Peripheral. |
| 73 | +* :kconfig:option:`CONFIG_BT_SCAN` - Enables scanning for Bluetooth LE advertisements (Central only). |
| 74 | +* :kconfig:option:`CONFIG_BT_SCAN_FILTER_ENABLE` - Enables name-based filtering for scan results (Central only). |
| 75 | +* :kconfig:option:`CONFIG_BT_PATH_LOSS_MONITORING` - Enables the Bluetooth LE path loss monitoring feature on both devices. |
| 76 | +* :kconfig:option:`CONFIG_DK_LIBRARY` - Enables the LEDs on the development kits. |
| 77 | + |
| 78 | +Building and running |
| 79 | +******************** |
| 80 | + |
| 81 | +.. |sample path| replace:: :file:`samples/bluetooth/path_loss_monitoring` |
| 82 | + |
| 83 | +.. include:: /includes/build_and_run.txt |
| 84 | + |
| 85 | +.. |sample_or_app| replace:: sample |
| 86 | + |
| 87 | +.. |ipc_radio_dir| replace:: :file:`sysbuild/ipc_radio` |
| 88 | + |
| 89 | +.. include:: /includes/ipc_radio_conf.txt |
| 90 | + |
| 91 | +Testing |
| 92 | +======= |
| 93 | + |
| 94 | +|test_sample| |
| 95 | + |
| 96 | +1. Program one DK with the :file:`samples/bluetooth/path_loss_monitoring/central` code. |
| 97 | +#. Program another DK with the :file:`samples/bluetooth/path_loss_monitoring/peripheral` code. |
| 98 | +#. Power on both devices. |
| 99 | +#. The Central will start scanning and connect automatically to the Peripheral. |
| 100 | +#. Once connected, observe the LEDs on the Central to evaluate signal strength: |
| 101 | + |
| 102 | + * Bring the devices closer or move them farther apart to change the signal quality. |
| 103 | + * Optionally, place an obstruction between the devices to see how this affects signal quality. |
| 104 | +#. Monitor the virtual serial ports for logs showing connection status and real-time path loss. |
| 105 | + |
| 106 | +Sample output |
| 107 | +============= |
| 108 | + |
| 109 | +The following output is logged from the Central device: |
| 110 | + |
| 111 | +.. code-block:: console |
| 112 | +
|
| 113 | + [00:00:01.000,000] <inf> central_unit: Starting path loss monitoring sample |
| 114 | + [00:00:01.500,000] <inf> central_unit: Scanning for peripherals... |
| 115 | + [00:00:03.020,000] <inf> central_unit: Found peripheral: FF:EE:DD:CC:BB:AA |
| 116 | + [00:00:03.050,000] <inf> central_unit: Connection to FF:EE:DD:CC:BB:AA |
| 117 | + [00:00:03.800,000] <inf> central_unit: Connected to FF:EE:DD:CC:BB:AA |
| 118 | + [00:00:03.810,000] <inf> central_unit: Path loss monitoring enabled |
| 119 | + [00:00:05.010,000] <inf> central_unit: Zone 0. Path loss: 30 dBm |
| 120 | + [00:00:06.010,000] <inf> central_unit: Zone 1. Path loss: 45 dBm |
| 121 | + [00:00:07.010,000] <inf> central_unit: Zone 2. Path loss: 63 dBm |
| 122 | +
|
| 123 | +Dependencies |
| 124 | +************ |
| 125 | + |
| 126 | +This sample uses the following |NCS| libraries: |
| 127 | + |
| 128 | +* :ref:`nrf_bt_scan_readme` |
| 129 | +* :ref:`dk_buttons_and_leds_readme` |
| 130 | + |
| 131 | +It uses the following Zephyr libraries: |
| 132 | + |
| 133 | +* :file:`include/zephyr/bluetooth/bluetooth.h` |
| 134 | +* :file:`include/zephyr/bluetooth/conn.h` |
| 135 | +* :file:`include/zephyr/bluetooth/uuid.h` |
| 136 | +* :file:`include/zephyr/bluetooth/addr.h` |
| 137 | +* :file:`include/zephyr/bluetooth/gap.h` |
| 138 | +* :file:`include/zephyr/logging/log.h` |
| 139 | +* :file:`include/zephyr/kernel.h` |
| 140 | +* :file:`include/bluetooth/scan.h` |
| 141 | +* :file:`include/dk_buttons_and_leds.h` |
0 commit comments