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 via the Arduino library manager.
Open up the Arduino library manager:
Search for the Adafruit BluefruitLE nRF51 library and install it
We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
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:
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)
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
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);
Page last edited March 08, 2024
Text editor powered by tinymce.