Skip to main content

Set your pulse racing with Genuino 101 and Bluetooth LE

Heart and Soul

For the observant amongst us, or the well-informed who read Andrew Back's recent blog, you would have noticed the small Bluetooth logo and aerial trace etched on the corner of the new Genuino 101 board. Although it looks like a mistake with the solder mask, for Arduino fans building wearables or IoT projects this is exciting news. Now you can connect to your latest creations wirelessly using Bluetooth Low Energy technology. Bluetooth LE has been specially designed to not only connect devices together in an ultra-power efficient way, it can also directly connect devices to applications running on smart phones and tablets.

In this article I'm going to take a hands-on look at the Heart Rate Monitor tutorial Arduino have developed to see how easy it is to connect the Genuino 101 to my smart phone and share data across the wireless link.

Arduino IDE

First step is to install version 1.6.7 of the Arduino IDE. I'm working in a Linux development environment (Ubuntu Wily) but there are good instructions on the Arduino website for those of you who are less fortunate. This version was not available in the distro repositories at the time of writing.

By uncompressing and running the install script in my home directory the IDE directory was created along with a launcher on the desktop. Additional software from Intel is required which is installed using the Board Manager from within the IDE. Just be patient with this as it took a good 10 mins or so to install on my laptop.

A final and important step is to run as sudo the udev script buried in a hidden directory under your users home


This allows the IDE correct privileges to connect and upload new sketches.

To test, select the Genuino 101 option in the Tools menu and upload Blink. If all is well output will appear in the bottom window of the IDE and after a few second the tiny LED near pin 13 should be flashing.

Total Eclipse of the Heart 

Don't Phunk With my Heart

Now the interesting bit. For the sketch - example link, unless you own an actual heart rate monitor (they are available) you can simulate output from such a sensor by connecting a 10K potentiometer to one of the analogue inputs.

The on-board ADC converts the voltage divider reading into a value that simulates heart rate, between 0 and 100 bpm. The LED attached to one of the digital outputs illuminates following a successful Bluetooth connection to the board.

Closer to the Heart

The sketch starts by including the CurieBLE.h library provided by the IDE and then creates a BLE Periferal object and configures it as a BLE Heart Rate service with a notification characteristic when the heart rate changes. The BLE specification is extensible and allows the creation of domain specific application profiles. For this example we are using a Heart Rate profile so that the client, in my case my smart phone app knows how to consume the connection. 

Once initialised the code goes into a loop and waits for a client to connect, once it has, it continuously calls the updateHeartRate() function. This passes the heart rate reading to the client. I changed this function by commenting out the if statement so that the value is sent every time the loop executes, not just when it changes.

[Code snippet
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
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
End of code snippet]

Listen to your heart

So that you can monitor your Bluetooth service you'll need a client device running an app capable of attaching to a BLE heart rate service. Fortunately Nordic have just such a handy app available for free download on iPhone and Android. Install this on your handset, launch it and choose the HRM icon and you should see your Genuino broadcasting. If everything connects, the LED will glow and the nice graph of your simulated heart rate will start displaying on the screen. If you don't get a connection try pressing the master reset button on the board.

Unbreak My Heart

Straight from the heart

With just a few components and lines of code we have a pretty impressive heart rate monitoring device that connects wirelessly over Bluetooth to an app on a smart phone, opening up all kinds of exciting possibilities for sensing IoT applications. Let us know what you make with yours.

Available from RS Components

Realted Articles - Say Hello to Genuino 101!

I'm an engineer and Linux advocate with probably more SBCs than a Chandrayaan-3 moon lander