Bluetooth: Central Heart Rate Monitor with Coded PHY

The Central Heart Rate Monitor with Coded PHY offers similar functionality to the Heart-rate Monitor (Central) sample from Zephyr. However, this sample specifically looks for heart rate monitors using LE Coded PHY.

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

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

nRF54L15 DK (emulating nRF54L05)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l05/cpuapp

nRF54H20 DK

PCA10175

nrf54h20dk

nrf54h20dk/nrf54h20/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

The sample also requires a device running a Heart Rate Server with LE Coded PHY support to connect to. For example, another development kit running the Bluetooth: Peripheral Heart Rate Monitor with Coded PHY sample.

Overview

The sample demonstrates a Bluetooth® LE Central role functionality by scanning for other Bluetooth LE devices that run a Heart Rate Server with LE Coded PHY support, which is not available in Zephyr Bluetooth LE Controller. See Controller for more information. It then establishes a connection to the first Peripheral device in range. You can use it together with the Bluetooth: Peripheral Heart Rate Monitor with Coded PHY sample. The sample enables the CONFIG_BT_EXT_ADV_CODING_SELECTION Kconfig option to use the Advertising Coding Selection Host feature to provide more detailed information on the advertiser’s primary and secondary PHYs. This allows the application to report whether the LE Coded PHY S=2 or S=8 coding schemes were used as the advertiser’s primary and secondary PHYs. When the CONFIG_BT_EXT_ADV_CODING_SELECTION Kconfig option is disabled, the application only indicates that LE Coded PHY was used, with no detailed information on the coding scheme.

Building and running

This sample can be found under samples/bluetooth/central_hr_coded 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, you can test it by connecting to another development kit that runs the Bluetooth: Peripheral Heart Rate Monitor with Coded PHY.

  1. Connect to the kit that runs this sample with a terminal emulator (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.

  2. Reset the kit.

  3. Program the other kit with the Bluetooth: Peripheral Heart Rate Monitor with Coded PHY sample.

  4. Wait until the Coded advertiser is detected by the Central. In the terminal window, check for information similar to the following:

    Filters matched. Address: xx.xx.xx.xx.xx.xx (random) connectable: yes Primary PHY: S=8 Coded Secondary PHY S=8 Coded
    Connection pending
    Connected: xx.xx.xx.xx.xx.xx (random), tx_phy LE Coded, rx_phy LE Coded
    The discovery procedure succeeded
    
  5. Observe that the received notifications are output in the terminal window:

    [SUBSCRIBED]
    Heart Rate Measurement notification received:
    
      Heart Rate Measurement Value Format: 8 - bit
      Sensor Contact detected: 1
      Sensor Contact supported: 1
      Energy Expended present: 0
      RR-Intervals present: 0
    
      Heart Rate Measurement Value: 113 bpm
    

Dependencies

This sample uses the following nRF Connect SDK libraries:

In addition, it uses the following Zephyr libraries:

  • include/zephyr/types.h

  • include/errno.h

  • include/zephyr.h

  • include/sys/printk.h

  • include/sys/byteorder.h

  • Kernel Services:

    • include/kernel.h

  • API:

  • include/bluetooth/bluetooth.h

  • include/bluetooth/conn.h

  • include/bluetooth/gatt.h

  • include/bluetooth/uuid.h