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.
The sample supports the following development kits:
If you use nRF5340 DK, the additional configuration of the network core will be taken from the
For more details, see Image-specific variables.
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.
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.
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.
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:
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.
This sample implements the vendor-specific service.
The 128-bit service UUID is
The 128-bit characteristic UUID is
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.
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.
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.
See Configuring your application 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
- 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.
This sample can be found under
samples/bluetooth/peripheral_power_profiling in the nRF Connect SDK folder structure.
To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Building and programming an application for other building and programming scenarios and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.
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 nRF Connect for Desktop and Power Profiler Kit II (PPK2)
Set up Power Profiler Kit II (PPK2) and prepare your development kit for current measurement.
Run the Power Profiler app from nRF Connect for Desktop.
Open a serial port connection to the kit using a terminal emulator that supports VT100/ANSI escape characters (for example, PuTTY). See How to connect with PuTTY for the required settings.
Reset your development kit.
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.
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.
Connect to the device through the Bluetooth Low Energy app.
Observe the power consumption on the current connection interval.
Set different connection parameters:
Click Settings for the connected device in the Bluetooth Low Energy app.
Select Update connection.
Set new connection parameters.
Click Update to negotiate new parameters with your device.
Observe the power consumption with the new connection parameters.
In 000016301212EFDE1523785FEABCD123, click Notify for the characteristic.
Observe that notifications are received.
Monitor the power consumption during notification sending.
After the timeout set by the CONFIG_BT_POWER_PROFILING_NOTIFICATION_TIMEOUT option, your development kit disconnects and enters the system off mode.
Repeat this test using different wake-up methods and different parameters, and monitor the power consumption for your new setup.
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: