The Bluetooth Special Interest Group has a standardized GATT (Generitt ATTribute Profile) for heart rate monitors called the Heart Rate profile. (You can see a list of all the GATT services here.)
This defines the commands and data that can be exchanged between the heart rate sensor device and the client device such as a phone, tablet, or BLE capable microcontroller (like we'll use in our project).
If you want to see how the Bluetooth SIG defines a GATT, such as the Heart Rate Service, you can look at the official XML file here.
Even better, run that URL through a code beautifier, such as codebeatify.org for a more human-readable version.
The Heart Rate service defines a three characteristics that can be served from the heart rate monitor (HRM) to a connected device.
Heart Rate Measurement
The most important for most needs is the Heart Rate Measurement Values characteristic which serves up the following information:
- Heart rate, in beats per minute (BPM)
- Contact -- if the device is in contact with the body or not
- Energy Expended, in kilojoules
- RR Intervals in 1024ths of seconds -- this is the measurement of intervals between beats
Body Sensor Location
Heart rate monitors will also include a characteristic for the intended location of the monitor on the body. This is built into the sensor firmware, not something that the device is determining on the fly! Standard values include:
- Ear Lobe
Heart Rate Control Point
If the HRM includes the Energy Expended feature, the heart rate control point characteristic is used to allow the client device to write control points to the HRM.
When we first connect to the device, we can see some data advertised including the device name, available services, connection parameters, manufacturer name, revision number, and more.
In this image we can see the HRM device (RHYTHM+) has been connected, and the Heart Rate Measurement characteristic is reporting its data.
If we request a read of the Body Sensor Location characteristic, we receive it as shown here: