Bluetooth: Peripheral power profiling

The Peripheral power profiling sample can be used to measure power consumption when Bluetooth® Low Energy stack is used for communication. You can measure power consumption during advertising and data transmission. For this purpose, the sample uses the vendor-specific service and demonstrates advertising in a connectable and non-connectable mode.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF54LV10 DK

PCA10188

nrf54lv10dk

nrf54lv10dk/nrf54lv10a/cpuapp/ns nrf54lv10dk/nrf54lv10a/cpuapp

nRF54LS05 DK

PCA10214

nrf54ls05dk

nrf54ls05dk/nrf54ls05b/cpuapp nrf54ls05dk/nrf54ls05a/cpuapp

nRF54LM20 DK

PCA10184

nrf54lm20dk

nrf54lm20dk/nrf54lm20b/cpuapp/ns nrf54lm20dk/nrf54lm20b/cpuapp nrf54lm20dk/nrf54lm20a/cpuapp/ns nrf54lm20dk/nrf54lm20a/cpuapp

nRF54LC10 DK

PCA10226

nrf54lc10dk

nrf54lc10dk/nrf54lc10a/cpuapp/ns nrf54lc10dk/nrf54lc10a/cpuapp

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp/ns nrf54l15dk/nrf54l15/cpuapp

nRF54L15 DK (emulating nRF54L10)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l10/cpuapp/ns nrf54l15dk/nrf54l10/cpuapp

nRF54L15 DK (emulating nRF54L05)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l05/cpuapp

nRF54H20 DK

PCA10175

nrf54h20dk

nrf54h20dk/nrf54h20/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp/ns nrf5340dk/nrf5340/cpuapp

nRF52 DK

PCA10040

nrf52dk

nrf52dk/nrf52832

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

nRF52833 DK

PCA10100

nrf52833dk

nrf52833dk/nrf52833

Optionally, you can use the Power Profiler Kit II (PPK2) for power profiling and optimizing your configuration. You can use also your proprietary solution for measuring the power consumption.

Overview

This sample uses Zephyr’s power management mechanism to implement the low power mode and the system off mode.

Low power mode

The application enters CPU sleep mode when the kernel is in idle state, which means it has nothing to schedule. Wake-up events are interrupts triggered by one of the SoC peripheral modules, such as RTC or SystemTick.

System off mode

This is the deepest power saving mode the system can enter. In this mode, all core functionalities are powered down, and most peripherals are non-functional or non-responsive. The only mechanisms that are functional in this mode are reset and wake-up.

Note

Currently, the System off mode is not supported by this sample for the nRF54H20 platform.

To wake up your development kit from the system off state, you have the following options:

  • Press the RESET button on your development kit.

  • Press Button 1 to start connectable advertising.

  • Press Button 2 to start non-connectable advertising.

  • Approach the NFC field of the development kit antenna.

The development kit starts advertising automatically. If you use a mobile phone, it connects and bonds with your device.

When you establish a connection with the central device, you can test different connection parameters to optimize the power consumption. When the central device enables the notification characteristic, your development kit starts sending notifications until the timeout expires. The device disconnects from the central and enters the system off mode. You can press a button or bring your phone close to the NFC antenna to wake up the device and continue testing.

For more details about power saving, refer to the Power optimization section.

Power profiling

You can use the Power Profiler Kit II (PPK2) for power profiling with this sample. See the device documentation for details about preparing your development kit for measurements.

The following parameters have an impact on power consumption:

  • Connection interval

  • Advertising duration

  • Latency

  • Notifications data size and interval

You can configure these parameters with the Kconfig options. If your central device is the Bluetooth Low Energy app from nRF Connect for Desktop, you can use it to change the current connection parameters.

Example measurements:

Power consumption measurement

Connection interval 150 ms, the signal peaks on the chart indicate connection event every 150 milliseconds interval.

Non-connectable advertising measurement

Non-connectable advertising setup: Minimal interval - 1000 ms, maximum interval - 1200 ms.

Service UUID

This sample implements the vendor-specific service.

The 128-bit service UUID is 00001630-1212-EFDE-1523-785FEABCD123.

Characteristics

The 128-bit characteristic UUID is 00001630-1212-EFDE-1524-785FEABCD123. This characteristic value can be read or sent by the notification mechanism. The value is an array filled with zeroes. You can configure the length of data using the CONFIG_BT_POWER_PROFILING_DATA_LENGTH Kconfig option.

This characteristic has a CCC descriptor associated with it.

User interface

The sample uses buttons and LEDs to provide a simple user interface.

LED 1:

Blinks, toggling on/off every second, when the main loop is running and the device is advertising. Off when the device is in system off state.

LED 2:

Lit when an NFC field is detected.

Button 1:

Starts connectable advertising and wakes up the SoC from the system off state.

Button 2:

Starts non-connectable advertising and wakes up the SoC from the system off state.

Note

When you use buttons to wake up the SoC from the system off state, the button state is read in the main thread after booting the Zephyr kernel. This causes a delay between the SoC wake up and button press processing. If you want to start advertising on system start, you must keep pressing the button until you see a log message confirming the advertising start on the terminal.

Configuration

See Configuring and building for information about how to permanently or temporarily change the configuration.

The Peripheral Power Profiling sample allows configuring some of its settings using Kconfig. You can set different options to monitor the power consumption of your development kit. You can modify the following options (available in the Kconfig file at samples/bluetooth/peripheral_power_profiling):

CONFIG_BT_POWER_PROFILING_DATA_LENGTH - Notification data length

Sets the length of the data sent through notification mechanism.

CONFIG_BT_POWER_PROFILING_NOTIFICATION_INTERVAL - Notification interval

Sets the notification send interval in milliseconds. Notification data is sent on every interval expiration. Notifications are started when the central device enables it by writing to the characteristic CCC descriptor.

CONFIG_BT_POWER_PROFILING_NOTIFICATION_TIMEOUT - Notification timeout

Sets the notification timeout in milliseconds. When this timeout fires the device will stop sending notifications. After that, the sample disconnects and enters the system off mode.

CONFIG_BT_POWER_PROFILING_CONNECTABLE_ADV_DURATION - Connectable advertising duration

Sets the connectable advertising duration in N*10 milliseconds unit. If the connection is not established during advertising, the device enters the system off state.

CONFIG_BT_POWER_PROFILING_NON_CONNECTABLE_ADV_DURATION - Non-connectable advertising duration

Sets the non-connectable advertising duration in N*10 milliseconds unit. When the advertising ends, the device enters the system off state if there is no outgoing connection.

CONFIG_BT_POWER_PROFILING_NFC_ADV_DURATION - Advertising duration when the NFC field is detected

Sets the advertising duration when the NFC field is detected in N*10 milliseconds unit. If the connection was not established during advertising, the device enters the system off state.

CONFIG_BT_POWER_PROFILING_CONNECTABLE_ADV_INTERVAL_MIN - Connectable advertising minimum interval

Sets the connectable advertising minimum interval in 0.625 milliseconds unit.

CONFIG_BT_POWER_PROFILING_CONNECTABLE_ADV_INTERVAL_MAX - Connectable advertising maximum interval

Sets the connectable advertising maximum interval in 0.625 milliseconds unit.

CONFIG_BT_POWER_PROFILING_NON_CONNECTABLE_ADV_INTERVAL_MIN - Non-connectable advertising minimum interval

Sets the non-connectable advertising minimum interval in 0.625 milliseconds unit.

CONFIG_BT_POWER_PROFILING_NON_CONNECTABLE_ADV_INTERVAL_MAX - Non-connectable advertising maximum interval

Sets the non-connectable advertising maximum interval in 0.625 milliseconds unit.

CONFIG_BT_POWER_PROFILING_LED_DISABLED - Disable LEDs

Disables the LEDs to reduce power consumption.

CONFIG_BT_POWER_PROFILING_NFC_DISABLED - Disable NFC

Disables the NFC to reduce power consumption.

The console is disabled by default to reduce power consumption. To enable the console, set the following Kconfig options to y:

Building and running

This sample can be found under samples/bluetooth/peripheral_power_profiling 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

This testing procedure assumes that you are using nRF Connect for Mobile or nRF Connect for Desktop. After programming the sample to your development kit, you need another device for measuring the power consumption. Power Profiler Kit II (PPK2) is the recommended device for the measurement.

Testing with Bluetooth Low Energy app and Power Profiler Kit II (PPK2)

  1. Set up Power Profiler Kit II (PPK2) and prepare your development kit for current measurement.

  2. Run the Power Profiler app from nRF Connect for Desktop.

  3. To see terminal messages (at the cost of a very small increase in power consumption), enable the following Kconfig options:

  4. Open a serial port connection to the kit using a terminal emulator that supports VT100/ANSI escape characters (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.

  5. Reset your development kit.

  6. Observe that the sample starts.

    The device enters the system off state after five seconds. Observe a significant power consumption drop when the device enters the system off state.

  7. Use the device buttons to wake up your device and start advertising or approach the NFC field of the kit antenna.

    You can measure power consumption during advertising with different intervals. Use the Kconfig options to change the interval or other parameters.

  8. Connect to the device through the Bluetooth Low Energy app.

    Observe the power consumption on the current connection interval.

  9. Set different connection parameters:

    1. Click Settings for the connected device in the Bluetooth Low Energy app.

    2. Select Update connection.

    3. Set new connection parameters.

    4. Click Update to negotiate new parameters with your device.

  10. Observe the power consumption with the new connection parameters.

  11. In 000016301212EFDE1523785FEABCD123, click Notify for the characteristic.

  12. Observe that notifications are received.

    Monitor the power consumption during notification sending.

  13. After the timeout set by the CONFIG_BT_POWER_PROFILING_NOTIFICATION_TIMEOUT option, your development kit disconnects and enters the system off mode.

  14. Repeat this test using different wake-up methods and different parameters, and monitor the power consumption for your new setup.

Dependencies

This sample uses the following nRF Connect SDK libraries:

It uses the Type 2 Tag library from sdk-nrfxlib:

In addition, it uses the following Zephyr libraries:

  • include/zephyr/sys/kernel.h

  • include/zephyr/sys/atomic.h

  • Settings

  • API:

    • include/zephyr/bluetooth/bluetooth.h

    • include/zephyr/bluetooth/conn.h

    • include/zephyr/bluetooth/uuid.h

    • include/zephyr/bluetooth/gatt.h

  • Power Management:

    • include/zephyr/pm/pm.h

    • include/zephyr/pm/policy.h