Heart Rate Sensor
Table of Contents
Introduction
The heart_rate project implements a simple Bluetooth low energy peripheral device with GATT services and implements the Heart Rate Profile. This project can be a framework for developing many different heart rate sensor applications.
This project uses a single stack and app configuration. It is summarized in the table below:
App Build Configuration | Compatible Stack Configuration | Description |
---|---|---|
FlashROM_StackLibrary | FlashROM_Library | Application build configuration linked to Stack library (fully executable) |
FlashROM_Library configurations use the stack library configuration, which is explained here.
This document discusses the procedure for using the heart_rate application when the FlashROM_StackLibrary configurations are used. The project can also be modified to support other configurations similar to the simple_peripheral project.
Hardware Prerequisites
The default heart_rate configuration uses the LAUNCHXL-CC2640R2. This hardware configuration is shown in the below image:
For custom hardware, see the Running the SDK on Custom Boards section of the BLE5-Stack User’s Guide.
Software Prerequisites
For information on what versions of Code Composer Studio and IAR Embedded Workbench to use, see the Release Notes located in the docs/ble5stack folder. For information on how to import this project into your IDE workspace and build/run, please refer to The CC2640R2F Platform section in the BLE5-Stack User’s Guide.
Service/Profile Table
This project contains 2 services. The Heart Rate has 3 characteristics, while the Battery service has 1 characteristic.
Characterisitic | UUID | Format | Properties | Profile Source |
---|---|---|---|---|
1 | 0x2A37 | 1 Byte Integer | Notify | heart_rate.c |
2 | 0x2A38 | 1 Byte Integer | Read | heart_rate.c |
3 | 0x2A39 | 1 Byte Integer | Write | heart_rate.c |
Usage
This application does not use any display interfaces. It does use the following buttons with descriptions:
Key | Description |
---|---|
BTN-1 | Toggle advertising |
BTN-2 | Change format of Heart Rate Measurement notification |
This document will use Android BLE Scanner as the phone app that will act as the central device that will connect to the heart_rate application. BLE Scanner can be downloaded free of charge on the Play Store.
Once the heart_rate sample application starts, press BTN-1 on the CC2640R2 LaunchPad to start advertising.
Advertising is not enabled by default upon startup, however, this can changed by setting AUTO_ADV to TRUE:
Usng BLE scanner to scan for the device, you should see a device with the name of “Heart Rate Sensor” (note that the navigation might be slightly different depending on your mobile application):
If there is more than one device with the same name, the RSSI value in the colored circles on the left can be used to find which device you are trying to connect to. Press the “CONNECT” button to connect to the device. Once connected, in BLE Scanner, you should be able to see all the services on the heart_rate device:
You should see 1 service, which is labeled as “HEART RATE SERVICE” (this may be slightly different for other smartphone applications). It will also provide its UUID. Clicking on this service will display the 3 characteristics that it contains, with information about each characteristic:
The following sections detail the functions and operations of each of the characteristics.
Heart Rate Measurement (UUID: 0x2A37)
This characteristic is used to notify simulated heart rate measurements with default size of 1 byte. As shown below, there is a circle with an “N”, next to “HEART RATE MEASUREMENT”:
This is the button used to enable notification. The value for this characteristic is set to “0x0000” by default, and it can be changed by pressing the “N” button. Upon pressing the Notify button, the app will write a “0x0001” to the CCCD of this Heart Rate Measurement characteristic to enable notification.
Pressing BTN-2 will change the format of the notification. See the Heart Rate Service for more details.
The heart rate measurement value will be updated(notified) periodically in BLE Scanner with simulated values:
The figure above shows that the current value of the heart rate is 75 beats per minute.
Sensor Location (UUID: 0x2A38)
This characteristic has read property only, it indicates where in the body the sensor is located. Its value can be read by pressing the “R” button on the app to read the value. It has a default value of 0x02 (WRIST). The app will automatically enumerate the value since it is a standard adopted profile (this may be slightly different with other smartphone applications).
Control Point (UUID: 0x2A39)
This characteristic has write property only. Its value can be written to by pressing the “W” button on the text. It has a default value of 0x00. See the Heart Rate Service for more details on the supported control point commands.