Bluetooth Low Energy


Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

Getting Started with BLE on mbed

We will demonstrate how to build a Heart Rate Monitor (HRM) using Nordic nRF51822 platform. For simplicity we are using the simulated Heart Rate Monitor but you can easily integrate a real heart rate sensor.

Components required

• Nordic nRF51822: The nRF51822-mKIT is a low cost ARM mbed enabled development board for Bluetooth® Smart designs with the nRF51822 SoC. The kit gives access to all GPIO pins via pin headers and incorporates a coin-cell battery holder for portability enabling in situ evaluation and test

/media/uploads/pratulsharma/nor1.png

  • Mini-B USB cable for power and mass storage interface.
  • Account on www.mbed.org
  • PC or laptop (to use mbed online IDE)

Check out other BLE hardware platforms supported on mbed here.

Steps to follow

  • Connect Nordic nRF51822 development board to your computer using a USB cable.
  • mbed will appear under removable storage. Click on MBED. An html file will appear.

  • Click on the HTML file (MBED). It will direct you to mbed website.

/media/uploads/pratulsharma/nor31.png

/media/uploads/pratulsharma/nor41.png

  • Login to mbed using your username and password
  • Click on “Import this program” tab.
  • Click on “Add Platform”

/media/uploads/pratulsharma/nor61.png

  • Following page will appear in a new tab. Scroll down and click on Nordic nRF51822

/media/uploads/pratulsharma/nor71.png

  • Following page will appear in the same tab. Click on “Add to your mbed Compiler”

/media/uploads/pratulsharma/nor81.png

  • Following page will appear in the same tab. Click on “Open mbed Compiler”.

/media/uploads/pratulsharma/nor91.png

  • Following page will appear in the same tab. Select “BLE_HeartRate” from the pull-down menu as shown below.

/media/uploads/pratulsharma/nor101.png

  • All the relevant libraries and programs will be imported to your workspace. Click on compile. This will generate binary file. Drag and drop binary file to Nordic nRF51822 development board. Click the “Reset” button on the board to run the firmware.
  • Setup mobile phone app Go to App Store or Google Play and search for “nRFready utility” Install the app.

/media/uploads/pratulsharma/nor121.png

  • Open the app and select Bluetooth Smart

/media/uploads/pratulsharma/nor131.png

  • Click Connect. Select Nordic_HRM (the default name) in the list. Once connected. you can observe the heart rate data in the graph. The simulated heart reading will start from 100 and increase up to 175 and then reset back to 100.

/media/uploads/pratulsharma/nor141.png

You can also play around with following parameters in the code to see how it affects the output.

  1. define MIN_CONN_INTERVAL 250 /< Minimum connection interval (250 ms) */
  2. define MAX_CONN_INTERVAL 350 /< Maximum connection interval (350 ms). */
  3. define CONN_SUP_TIMEOUT 6000 /< Connection supervisory timeout (6 seconds). */
  4. define SLAVE_LATENCY 4

Code Walk through

You can find a good explanation of how the program works here.

More examples

You can find many more example programs under the Code section of the following page

http://developer.mbed.org/teams/Bluetooth-Low-Energy/