nRF5 SDK v15.2.0
Heart Rate Application
This example requires one of the following SoftDevices: S132, S140, S332

Important: Before you run this example, make sure to program the SoftDevice.

The Heart Rate Application is an example that implements the Heart Rate profile using the hardware delivered in the nRF5 Development Kit.

The application includes the three services in the Heart Rate profile:

When the application starts, the Board Support Package is initialized. Next, three timers are started. These timers control the generation of various parts of the Heart Rate Measurement characteristic value:

Also, a timer for generating battery measurements is started.

The sensor measurements are simulated the following way:

When notification of Heart Rate Measurement characteristic is enabled, the Heart Rate Measurement, containing the current value for all the components of the Heart Rate Measurement characteristic, is notified each time the Heart Rate measurement timer expires. When notification of Battery Level characteristic is enabled, the Battery Level is notified each time the Battery Level measurement timer expires.

This example demonstrates the use of Low Energy Secure Connections (LESC). The default cryptographic backend used for LESC is CC310 (when run on nRF52840) or Oberon (for other SoCs). To use micro-ecc instead, follow the steps in Enabling micro-ecc support in selected examples.

This application is not power optimized!
The application will stop advertising after 3 minutes and go to system-off mode. Push Button 1 to restart advertising.
RTT is also available as a logger backend in case UART can't be used. You can configure the nrf_log backend in the sdk_config.h.


You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\ble_app_hrs

Button assignments: BSP BLE Button Assignments


Test the Heart Rate Application with the nRF Toolbox app, which is available on both iOS (App Store) and Android (Google Play).

You can also test the application with nRF Connect by performing the following steps:

  1. Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  2. Enable LESC pairing in nRF Connect. Click the settings button, select "Security Settings", check "Enable LE Secure Connection pairing", and click "Apply".
  3. Connect to the device from nRF Connect (the device is advertising as 'Nordic_HRM'). Observe that the BSP_INDICATE_CONNECTED state is indicated.
  4. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the 'Play' button. Heart Rate notifications are received every second, and Battery Level notifications are received every two seconds.

Documentation feedback | Developer Zone | Subscribe | Updated