Make NTU Hackathon
Team for Make NTU Hackathon 2017 in Taipei. See the Wiki tab below for details on using the hardware available. The Code tab contains example code for all the hardware.
You are viewing an older revision! See the latest version
Program3_BLEHeartRate
This example demonstrates how to use the X-NUCLEO-IDB05A1 component with one of the STM32 Nucleo platforms to obtain heart rate information:
For the sake of simplicity and portability, the sensor in this case has been abstracted using a counter which counts up to a threshold and then recycles. The code can be easily extended to use the real heart rate sensor.
Technical details are better presented in the mbed Classic equivalent of this example.
Setup¶
First, attach the X-NUCLEO-IDB05A1 to the STM32 Nucleo platform as shown here:
To see the heart rate information on your phone, you need download a BLE Scanner App:
- nRF Master Control Panel for Android
- LightBlue for iPhone
Compile and Run¶
Building with mbed CLI
If you'd like to use mbed CLI to build this, then you should follow the instructions for mbed cli. The instructions here relate to using the developer.mbed.org Online Compiler
- Import Program3_BLEHeartRate to your online compiler.
- Porting work
- Update the BLE_API library if it is outdated: just right click at the BLE_API library and choose update all.
- Remove all instances of LED1 in main.cpp. The shield’s LED is on the same line as SPI CLK which will prevent the board from working.
main.cpp
// DigitalOut led1(LED1, 1); // led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
- Add the line #define IDB0XA1_D13_PATCH to X_NUCLEO_IDB0XA1/x_nucleo_idb0xa1/x_nucleo_idb0xa1_targets.h
x_nucleo_idb0xa1_targets.h
#define IDB0XA1_D13_PATCH
3.Compile and download the bin file to 'NODE_F429ZI' disk. Then reset the board.
4. Now open the BLE scanner on your phone. Reflesh the page to start a new scan. If everything is correct, you will see a device name bluenrg! listed.
5.Click the device to establish a connection. After that, several characteristics of Heart Rate will be shown as below:
6. Enter the Heart Rate Measurement item and click the Listen for notification tab to register for the notifications sent by the Heart Rate Measurement characteristic. If you see the heart rate value change every half second, Congratulations, you have made it!