The HeartRateMonitor example allows you to define a new GATT Service and associated GATT Characteristics, and update the characteristic values using standard AT commands.

Opening the Sketch

To open the ATCommand sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select heartratemonitor:

This will open up a new instance of the example in the IDE, as shown below:

Configuration

Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI

If Using Hardware or Software UART

This tutorial does not need to use the MODE pin, make sure you have the mode switch in CMD mode if you do not configure & connect a MODE pin

This demo uses some long data transfer strings, so we recommend defining and connecting both CTS and RTS to pins, even if you are using hardware serial.

If you are using a Flora or just dont want to connect CTS or RTS, set the pin #define's to -1 and Don't forget to also connect the CTS pin on the Bluefruit to ground! (The Flora has this already done)

If you are using RTS and CTS, you can remove this line below, which will slow down the data transmission

// this line is particularly required for Flora, but is a good idea 
  // anyways for the super long lines ahead!
  ble.setInterCharWriteDelay(5); // 5 ms

Running the Sketch

Once you upload the sketch to your board (via the arrow-shaped upload icon), and the upload process has finished, open up the Serial Monitor via Tools > Serial Monitor, and make sure that the baud rate in the lower right-hand corner is set to 115200:

If you open up an application on your mobile device or laptop that support the standard Heart Rate Monitor Service, you should be able to see the heart rate being updated in sync with the changes seen in the Serial Monitor:

nRF Toolbox HRM Example

The image below is a screenshot from the free nRF Toolbox application from Nordic on Android (also available on iOS), showing the incoming Heart Rate Monitor data:

CoreBluetooth HRM Example

The image below is from a freely available CoreBluetooth sample application from Apple showing how to work with Bluetooth Low Energy services and characteristics:

This guide was first published on Aug 07, 2015. It was last updated on Mar 08, 2024.

This page (HeartRateMonitor) was last updated on Apr 30, 2015.

Text editor powered by tinymce.