Professional Documents
Culture Documents
GETTING STARTED (/EN/GUIDE/HOMEPAGE) > Arduino/Genuino 101 (/en/Guide/Arduino101) > CurieBLE Heart Rate Monitor
ENGLISH
Hardware Required
- Genuino/Arduino 101 (//www.arduino.cc/en/Main/ArduinoBoard101)
- An Android or iOS device running the nRF Toolbox for BLE App
- A Potentiometer or other analog sensor
The Circuit
(//www.arduino.cc/en/uploads/Tutorial/gen101hrm_fzz.jpg)
1. Download the nRF Toolbox for BLE app for Android (https://play.google.com/store/apps/details?
id=no.nordicsemi.android.nrftoolbox&hl=it) or for iOS (https://itunes.apple.com/it/app/nrf-toolbox/id820906058?mt=8) free of
charge.
2. Wire up the potentiometer (or other analog sensor) to your Arduino 101 as shown in "the circuit" above.
3. Connect the Arduino 101 to your computer.
4. Launch the Arduino software and select Arduino 101 from the Tools > Board menu.
5. Upload the CurieBLEHeartRateMonitor example (found in File > Examples > CurieIMU). (The full code for the example is shown below.)
6. Launch the app. You should be presented with the home screen as depicted below.
(//www.arduino.cc/en/uploads/Tutorial/homeNRF.png)
- Click the heart icon in the centre of the screen, after which you will see a graph showing Beats per Minute over Time. This will not
show any data until connected with your Arduino.
- Press the connect button below the graph you should see the device "HeartRateSketch" (or whatever name you set).
- Click on the name of your device, and the data from the potentiometer should immediately start entering the graph as depicted
below. Of course, the potentiometer only emulates a heart rate to demonstrate the usage of the service.
(//www.arduino.cc/en/uploads/Tutorial/graphNRF.png)
Code
/*
Copyright (c) 2015 Intel Corporation. All rights reserved.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
This sketch example partially implements the standard Bluetooth Low-Energy Heart Rate service.
For more information: https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
*/
#include <CurieBle.h>
void setup() {
Serial.begin(9600); // initialize serial communication
pinMode(13, OUTPUT); // initialize the LED on pin 13 to indicate when a central is connected
/* Now activate the BLE device. It will start continuously transmitting BLE
advertising packets and will be visible to remote BLE central devices
until it receives a new connection */
blePeripheral.begin();
Serial.println("Bluetooth device active, waiting for connections...");
}
void loop() {
// listen for BLE peripherals to connect:
BLECentral central = blePeripheral.central();
void updateHeartRate() {
/* Read the current voltage level on the A0 analog input pin.
This is used here to simulate the heart rate's measurement.
*/
int heartRateMeasurement = analogRead(A0);
int heartRate = map(heartRateMeasurement, 0, 1023, 0, 100);
if (heartRate != oldHeartRate) { // if the heart rate has changed
Serial.print("Heart Rate is now: "); // print it
Serial.println(heartRate);
const unsigned char heartRateCharArray[2] = { 0, (char)heartRate };
heartRateChar.setValue(heartRateCharArray, 2); // and update the heart rate measurement characteristic
oldHeartRate = heartRate; // save the level for next comparison
}
}
[Get Code] (//www.arduino.cc/en/Tutorial/Genuino101CurieBLEHeartRateMonitor?action=sourceblock&num=1)
See Also
- Heart Rate Monitor (//www.arduino.cc/en/Tutorial/Genuino101CurieBLEHeartRateMonitor)
- Battery Monitor (//www.arduino.cc/en/Tutorial/Genuino101CurieBLEBatteryMonitor)
- Button LED (//www.arduino.cc/en/Tutorial/Genuino101CurieBLEButtonLED)
- Callback LED (//www.arduino.cc/en/Tutorial/Genuino101CurieBLECallbackLED)
- LED (//www.arduino.cc/en/Tutorial/Genuino101CurieBLELED)
Share
NEWSLETTER
Enter your email to sign up
2016 Arduino Copyright Notice (//www.arduino.cc/en/Main/CopyrightNotice) Contact us (//www.arduino.cc/en/Main/ContactUs)
About us (//www.arduino.cc/en/Main/AboutUs) Careers (//www.arduino.cc/Careers)
(https://www.ickr.com/photos/arduino_cc) (https://youtube.com/arduinoteam)