nRF5 SDK v17.1.0
ANT+ Heart Rate
This example requires the following SoftDevice: S212

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

The Heart Rate example applications show the usage of the Heart Rate Monitor profile.

Receiver

The Receiver application connects to the nearest heart rate monitor (HRM) in range and prints out incoming page data. The actual channel state is indicated by the ANT channel state indicator.

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ant\ant_plus\ant_hrm\hrm_rx

User interface

If a time-out occurs during search (30 seconds by default), the ANT channel is closed and the device is put into sleep mode. To wake it up, press Button 4. You can also put the device in sleep mode by pressing Button 4 while it is searching (see BSP ANT Button Module).

Transmitter

The Transmitter application simulates a Heart Rate Monitor transmitter. It transmits the heart rate information in the main data page (page 4). Device-specific information is transmitted at a slower rate in the background data pages (pages 1-3). The application prints out outgoing page data. The actual channel state is indicated by the ANT channel state indicator.

The profile information is generated by the ANT HRM simulator.

There are two ways to modify the profile information (heart rate):

You can select how the profile information is modified by using the "MODIFICATION_TYPE" field in the sdk_config.h file.

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ant\ant_plus\ant_hrm\hrm_tx

Testing

Note: You can use a custom channel or encryption when running any of the ANT examples. When adding a new channel or encryption, remember to update SoftDevice ANT event handler configuration.

You can test the Heart Rate example in different ways:

Testing the HRM Transmitter with the HRM Receiver

Note that UART is not available when you use the D52 Starter Kit from Garmin Canada.

  1. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  2. Ensure that the UART tracing settings are configured in the Heart Rate Monitor (see Compile time configuration options).
  3. Compile and program the HRM Receiver. Observe that the receiver board indicates states following CHANNEL_TYPE_SLAVE/CHANNEL_TYPE_SLAVE_RX_ONLY.
  4. Compile and program the HRM Transmitter. Observe that the transmitter board indicates states following CHANNEL_TYPE_MASTER.
  5. After a while, observe that the receiver board is connected.

The following information should be output on the console for the transmitter:

ANT HRM channel 0 init
ANT HRM channel 0 open
HRM TX Page number:               0
Heart beat count:                 0
Computed heart rate:              0
Heart beat event time:            0.000s

HRM TX Page number:               0
Heart beat count:                 1
Computed heart rate:              150
Heart beat event time:            0.399s

HRM TX Page number:               0
Heart beat count:                 1
Computed heart rate:              150
Heart beat event time:            0.399s

The following information should be output on the console for the receiver:

ANT HRM channel 0 init
ANT HRM channel 0 open
HRM RX Page Number:               0
Heart beat count:                 159
Computed heart rate:              154
Heart beat event time:            14.083s

Page was updated

HRM RX Page Number:               0
Heart beat count:                 160
Computed heart rate:              156
Heart beat event time:            14.467s

Page was updated

HRM RX Page Number:               0
Heart beat count:                 160
Computed heart rate:              156
Heart beat event time:            14.467s

Page was updated

HRM RX Page Number:               2
Heart beat count:                 161
Computed heart rate:              160
Heart beat event time:            14.842s
Manufacturer ID:                  2
Serial No (upper 16-bits):        0xABCD

Page was updated

HRM RX Page Number:               0
Heart beat count:                 162
Computed heart rate:              162
Heart beat event time:            15.212s

Page was updated

If you are testing the HRM Transmitter button version, observe that the computed heart rate value increases when pressing Button 1 and decreases when pressing Button 2.

If you are testing the HRM Transmitter auto version, observe that the computed heart rate value periodically rises and falls.

Testing the HRM Transmitter using AntWare II

  1. Compile and program the HRM Transmitter. Observe that the transmitter board indicates states following CHANNEL_TYPE_MASTER.
  2. Run AntWare II. Select your ANT PC dongle (for example, ANTUSB-m) from the available devices. Configure the device channel by loading the device profile configuration from the following file: <InstallFolder>\examples\ant\ant_plus\ant_hrm\hrm_tx\hrm_rx_device_profile.xml. Alternatively, you can configure the device channel manually:
    1. Set the channel assignment to slave.
    2. Set the channel ID to "0, 120, 0".
    3. On the Basic tab, set the channel period to 8070 cycles (4,06 Hz) and the radio frequency to 2457 MHz.
    4. Keep the default for all other settings.
  3. Click the Auto-Open button. Observe that messages describing the received payload appear for each ANT message. These messages should look similar to the following fragment:
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-00-FF-FF-FF-09-60-F1-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-00-FF-FF-FF-A2-61-F2-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-00-FF-FF-FF-3B-63-F3-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-00-FF-FF-FF-D4-64-F4-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-80-FF-FF-FF-6D-66-F5-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-80-FF-FF-FF-06-68-F6-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-80-FF-FF-FF-9F-69-F7-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-80-FF-FF-FF-38-6B-F8-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-00-FF-FF-FF-D1-6C-F9-96
    Received BROADCAST_DATA_0x4E
      :: 4e, 00-00-FF-FF-FF-6A-6E-FA-96
    
    Each message can be decoded according to the ANT message protocol and the Heart Rate Monitor ANT+ device profile.

Testing the HRM examples with the ANT+ Simulator tools

To use the ANT+ Simulator tools, you must set the ANT+ Network Key to a proper value.

You can then use the ANT+ Display Simulator to test the HRM Transmitter and the ANT+ Sensor Simulator to test the HRM Receiver. See the documentation of the ANT+ Simulator tools at thisisant.com for information about how to use these tools.

Note
The ANT+ Network Key and ANT+ Simulator tools are available for ANT+ Adopters. Go to thisisant.com to become an ANT+ Adopter and access the key.

Documentation feedback | Developer Zone | Subscribe | Updated