Installing BLE Library

Install the Adafruit nRF51 BLE Library

In order to try out our demos, you'll need to download the Adafruit BLE library for the nRF51 based modules such as this one (a.k.a. Adafruit_BluefruitLE_nRF51)

You can check out the code here at github, but its likely easier to just download by clicking:

Rename the uncompressed folder Adafruit_BluefruitLE_nRF51 and check that the Adafruit_BluefruitLE_nRF51 folder contains Adafruit_BLE.cpp and Adafruit_BLE.h (as well as a bunch of other files)

Place the Adafruit_BluefruitLE_nRF51 library folder your arduinosketchfolder/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.

We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

After restarting, check that you see the library folder with examples:

Run first example

Lets begin with the beginner project, which we can use to do basic tests. To open the ATCommand sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select atcommand:

This will open up a new instance of the example in the IDE, as shown below:

Don't upload the sketch yet! You will have to begin by changing the configuration.

Go to the second tab labeled BluefruitConfig.h and find these lines

// SHARED SPI SETTINGS
// ----------------------------------------------------------------------------------------------
// The following macros declare the pins to use for HW and SW SPI communication.
// SCK, MISO and MOSI should be connected to the HW SPI pins on the Uno when
// using HW SPI.  This should be used with nRF51822 based Bluefruit LE modules
// that use SPI (Bluefruit LE SPI Friend).
// ----------------------------------------------------------------------------------------------
#define BLUEFRUIT_SPI_CS               8
#define BLUEFRUIT_SPI_IRQ              7
#define BLUEFRUIT_SPI_RST              6    // Optional but recommended, set to -1 if unused

And change the last line to:

#define BLUEFRUIT_SPI_RST              4   // Optional but recommended, set to -1 if unused

(The Bluefruit Feather has the reset on digital #4 not #6)

Now go back to the main tab atcommand and look for this line of code

/* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

Make sure that the second line is uncommented (it should be)

OK now you can upload to the Bluefruit Feather!
If you're using Ubuntu 15.04 or other Linux distributions and run into errors attempting to upload a program to the board, scroll up to the Ubuntu and Linux issue fix in the previous section

Uploading to the Feather Bluefruit LE

It's pretty easy to upload, first up make sure you have Adafruit Feather 32u4 selected on the boards dropdown as above. Also, in the Ports menu, look for the port labeled as such:

Now click the upload button on the Arduino IDE (or File Menu -> Upload)

If all is good you will see Done Uploading in the status bar

Uploading to a brand new board/Upload failures

If you are uploading for the first time to a new board, or if upload fails, pres the RESET mini button on the Feather 32u4 Bluefruit when you see the Yellow Arrow lit and the Uploading... text in the status bar. When you see the red LED pulsing on and off, you know the bootloader is running.

Don't click the reset button before uploading, unlike other bootloaders you want this one to run at the time Arduino is trying to upload

Run the sketch

OK check again that the correct port is selected

Then open up the Serial console. You will see the following:

This sketch starts by doing a factory reset, then querying the BLE radio for details. These details will be useful if you are debugging the radio. If you see the information as above, you're working! (Note that the dates and version numbers may vary)

AT command testing

Now you can try out some AT commands - check the rest of the learn guide for a full list. We'll just start with AT+HWGETDIETEMP which will return the approximate ambient temperature of the BLE chipset

OK now you know how to upload/test/communicate with your Feather 32u4 Bluefruit. Next up we have a bunch of tutorials who can follow for checking out the bluetooth le radio and apps.

For all the following examples, we share the same code between various modules so don't forget to make sure you have the RESET pin set to 4 in BluefruitConfig.h for each sketch before uploading, and that Hardware SPI mode is selected by checking for

      /* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
    
Last updated on 2016-01-13 at 03.52.48 PM Published on 2015-11-18 at 04.53.32 PM