Adafruit Feather M0 Bluefruit LE Created by lady ada Last updated on 2017-10-07 11:58:39 AM UTC
Guide Contents Guide Contents Overview Pinouts Power Pins Logic pins Bluefruit LE Module + Indicator LEDs Other Pins! SWD Pins Factory Reset Assembly Header Options! Soldering in Plain Headers Prepare the header strip: Add the breakout board: And Solder! Soldering on Female Header Tape In Place Flip & Tack Solder And Solder! 25 26 26 28 28 29 30 Power Management Battery + USB Power Power supplies Measuring Battery ENable pin Arduino IDE Setup https://adafruit.github.
Compilation Issues Manually bootloading Ubuntu & Linux Issue Fix Adapting Sketches to M0 Analog References Pin Outputs & Pullups Serial vs SerialUSB AnalogWrite / PWM on Feather/Metro M0 analogWrite() PWM range Missing header files Bootloader Launching Aligned Memory Access Floating Point Conversion How Much RAM Available? Storing data in FLASH Installing BLE Library Install the Adafruit nRF51 BLE Library Run first example Uploading to the Feather Bluefruit LE Compilation Issues Manually bootloading Run the
SPI Pins Software SPI Pins 69 70 Select the Serial Bus UART Based Boards (Bluefruit LE UART Friend & Flora BLE) SPI Based Boards (Bluefruit LE SPI Friend) ATCommand Opening the Sketch Configuration Running the Sketch BLEUart Opening the Sketch Configuration Running the Sketch HIDKeyboard Opening the Sketch Configuration Running the Sketch Bonding the HID Keyboard Android iOS OS X Controller Opening the Sketch Configuration Running the Sketch Using Bluefruit LE Connect in Controller Mode Streaming Sensor
Running the Sketch nRF Toolbox HRM Example CoreBluetooth HRM Example UriBeacon Opening the Sketch Configuration Running the Sketch HALP! 104 106 108 109 109 110 111 113 When using the Bluefruit Micro or a Bluefruit LE with Flora/Due/Leonardo/Micro the examples dont run? 113 I can't seem to "Find" the Bluefruit LE! 113 AT Commands Test Command Mode '=?' Write Command Mode '=xxx' Execute Mode Read Command Mode '?' Standard AT AT ATI ATZ ATE +++ General Purpose AT+FACTORYRESET AT+DFU AT+HELP AT+NVMWRITE AT+
AT+HWGPIO AT+HWGPIOMODE AT+HWI2CSCAN AT+HWVBAT AT+HWRANDOM AT+HWMODELED AT+UARTFLOW Beacon AT+BLEBEACON AT+BLEURIBEACON Deprecated: AT+EDDYSTONEENABLE AT+EDDYSTONEURL AT+EDDYSTONECONFIGEN AT+EDDYSTONESERVICEEN AT+EDDYSTONEBROADCAST BLE Generic AT+BLEPOWERLEVEL AT+BLEGETADDRTYPE AT+BLEGETADDR AT+BLEGETPEERADDR AT+BLEGETRSSI BLE Services AT+BLEUARTTX TX FIFO Buffer Handling AT+BLEUARTTXF AT+BLEUARTRX AT+BLEUARTFIFO AT+BLEKEYBOARDEN AT+BLEKEYBOARD AT+BLEKEYBOARDCODE Modifier Values 147 149 149 150 150 151 1
AT+BLEHIDMOUSEBUTTON AT+BLEHIDCONTROLKEY AT+BLEHIDGAMEPADEN AT+BLEHIDGAMEPAD AT+BLEMIDIEN AT+BLEMIDIRX AT+BLEMIDITX AT+BLEBATTEN AT+BLEBATTVAL BLE GAP AT+GAPCONNECTABLE AT+GAPGETCONN AT+GAPDISCONNECT AT+GAPDEVNAME AT+GAPDELBONDS AT+GAPINTERVALS AT+GAPSTARTADV AT+GAPSTOPADV AT+GAPSETADVDATA BLE GATT GATT Limitations AT+GATTCLEAR AT+GATTADDSERVICE AT+GATTADDCHAR AT+GATTCHAR AT+GATTLIST AT+GATTCHARRAW Debug AT+DBGMEMRD AT+DBGNVMRD AT+DBGSTACKSIZE AT+DBGSTACKDUMP © Adafruit Industries https://learn.adafruit.
History Version 0.7.7 Version 0.7.0 Version 0.6.7 Version 0.6.6 Version 0.6.5 Version 0.6.2 Version 0.5.0 Version 0.4.7 Version 0.3.
TX (0x0002) RX (0x0003) 209 209 Software Resources Bluefruit LE Client Apps and Libraries 210 210 Bluefruit LE Connect (Android/Java) Bluefruit LE Connect (iOS/Swift) 210 210 Bluefruit LE Connect for OS X (Swift) Bluefruit LE Command Line Updater for OS X (Swift) 211 212 Deprecated: Bluefruit Buddy (OS X) ABLE (Cross Platform/Node+Electron) Bluefruit LE Python Wrapper 213 214 215 Debug Tools 215 AdaLink (Python) Adafruit nRF51822 Flasher (Python) 216 216 BLE FAQ 218 Can I talk to Classic Blu
DFU Bluefruit Updates Downloads Datasheets Schematic Fab Print Device Recovery How to Recover a Bluefruit Board 1. Force DFU Mode at Startup 2. Update the Bluefruit Firmware BLEFRIEND32 Firmware (UART, 32KB SRAM) BLESPIFRIEND Firmware (SPI) 3. Flash a Test Sketch 4.
Overview Feather is the new development board from Adafruit, and like it's namesake it is thin, light, and lets you fly! We designed Feather to be a new standard for portable microcontroller cores. This is the Adafruit Feather M0 Bluefruit - our take on an 'all-in-one' Cortex M0+ Arduinocompatible + Bluetooth Low Energy with built in USB and battery charging.
At the Feather M0's heart is an ATSAMD21G18 ARM Cortex M0 processor, clocked at 48 MHz and at 3.3V logic, the same one used in the new Arduino Zero. This chip has a whopping 256K of FLASH (8x more than the Atmega328 or 32u4) and 32K of RAM (16x as much)! This chip comes with built in USB so it has USB-to-Serial program & debug capability built in with no need for an FTDI-like chip. To make it easy to use for portable projects, we added a connector for any of our 3.
Here's some handy specs! Like all Feather M0's you get: Measures 2.0" x 0.9" x 0.28" (51mm x 23mm x 8mm) without headers soldered in Light as a (large?) feather - 5.7 grams ATSAMD21G18 @ 48MHz with 3.3V logic/power 256KB of FLASH + 32KB of RAM No EEPROM 3.
Reset button The Feather M0 Bluefruit uses the extra space left over to add our excellent Bluefruit BTLE module + two status indicator LEDs © Adafruit Industries https://learn.adafruit.
The Power of Bluefruit LE The Bluefruit LE module is an nRF51822 chipset from Nordic, programmed with multi-function code that can do quite a lot! For most people, they'll be very happy to use the standard Nordic UART RX/TX connection profile. In this profile, the Bluefruit acts as a data pipe, that can 'transparently' transmit back and forth from your iOS or Android device. You can use our iOS App or Android App, or write your own to communicate with the UART service.
control You can do a lot more too! The Bluefruit can also act like an HID Keyboard (for devices that support BLE HID) Can become a BLE Heart Rate Monitor (a standard profile for BLE) - you just need to add the pulse-detection circuitry Turn it into a UriBeacon, the Google standard for Bluetooth LE beacons. Just power it and the 'Friend will bleep out a URL to any nearby devices with the UriBeacon app installed.
Pinouts The Feather M0 Bluefruit is chock-full of microcontroller goodness. There's also a lot of pins and ports. We'll take you a tour of them now! © Adafruit Industries https://learn.adafruit.
Power Pins © Adafruit Industries https://learn.adafruit.
GND - this is the common ground for all power and logic BAT - this is the positive voltage to/from the JST jack for the optional Lipoly battery USB - this is the positive voltage to/from the micro USB jack if connected EN - this is the 3.3V regulator's enable pin. It's pulled up, so connect to ground to disable the 3.3V regulator 3V - this is the output from the 3.3V regulator, it can supply 500mA peak Logic pins This is the general purpose I/O pin set for the microcontroller. All logic is 3.
for the lipoly battery so be aware that this pin naturally 'sits' at around 2VDC due to the resistor divider #10 - GPIO #10 #11 - GPIO #11 #12 - GPIO #12 #13 - GPIO #13 and is connected to the red LED next to the USB jack A0 - This pin is analog input A0 but is also an analog output due to having a DAC (digital-to-analog converter). You can set the raw voltage to anything from 0 to 3.3V, unlike PWM outputs this is a true analog output A1 thru A5 - These are each analog input as well as digital I/O pins.
Other Pins! RST - this is the Reset pin, tie to ground to manually reset the ATSAMD, as well as launch the bootloader manually ARef - the analog reference pin. Normally the reference voltage is the same as the chip logic voltage (3.3V) but if you need an alternative analog reference, connect it to this pin and select the external AREF in your firmware. Can't go higher than 3.3V! DFU - this is the force-DFU (device firmware upgrade) pin for over-the-air updates to the Bluefruit module.
The round pads on the right are for the ATSAMD21G18 (main processor). The rectangular pads to the left are for the nrf51822 inside the BLE module. You cannot connect these together to debug both at the same time! Factory Reset The (somewhat deceptively labeled) 'Reset' pad on the bottom of the PCB beside SWCLK and SWDIO is for Factory Reset. Connecting this pad to GND at startup will perform a factory reset, erasing any config settings and may be useful trying to recover a device in a faulty state.
Assembly We ship Feathers fully tested but without headers attached - this gives you the most flexibility on choosing how to use and configure your Feather Header Options! Before you go gung-ho on soldering, there's a few options to consider! The first option is soldering in plain male headers, this lets you plug in the Feather into a solderless breadboard Another option is to go with socket female headers.
We also have 'slim' versions of the female headers, that are a little shorter and give a more compact shape © Adafruit Industries https://learn.adafruit.
Finally, there's the "Stacking Header" option. This one is sort of the best-of-bothworlds. You get the ability to plug into a solderless breadboard and plug a featherwing on top. But its a little bulky Soldering in Plain Headers © Adafruit Industries https://learn.adafruit.
Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
Solder the other strip as well. © Adafruit Industries https://learn.adafruit.
You're done! Check your solder joints visually and continue onto the next steps Soldering on Female Header Tape In Place For sockets you'll want to tape them in place so when you flip over the board they don't fall out Flip & Tack Solder After flipping over, solder one or two points on each strip, to 'tack' the header in place © Adafruit Industries https://learn.adafruit.
And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
You're done! Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Power Management Battery + USB Power We wanted to make the Feather easy to power both when connected to a computer as well as via battery. There's two ways to power a Feather. You can connect with a MicroUSB cable (just plug into the jack) and the Feather will regulate the 5V USB down to 3.3V. You can also connect a 4.2/3.7V Lithium Polymer (Lipo/Lipoly) or Lithium Ion (LiIon) battery to the JST jack. This will let the Feather run on a rechargable battery.
The above shows the Micro USB jack (left), Lipoly JST jack (top left), as well as the 3.3V regulator and changeover diode (just to the right of the JST jack) and the Lipoly charging circuitry (to the right of the Reset button). There's also a CHG LED, which will light up while the battery is charging. This LED might also flicker if the battery is not connected.
Measuring Battery If you're running off of a battery, chances are you wanna know what the voltage is at! That way you can tell when the battery needs recharging. Lipoly batteries are 'maxed out' at 4.2V and stick around 3.7V for much of the battery life, then slowly sink down to 3.2V or so before the protection circuitry cuts it off. By measuring the voltage you can quickly tell when you're heading below 3.
ENable pin If you'd like to turn off the 3.3V regulator, you can do that with the EN(able) pin. Simply tie this pin to Ground and it will disable the 3V regulator. The BAT and USB pins will still be powered © Adafruit Industries https://learn.adafruit.
Arduino IDE Setup The first thing you will need to do is to download the latest release of the Arduino IDE. You will need to be using version 1.8 or higher for this guide Arduino IDE Download https://adafru.it/f1P After you have downloaded and installed the latest version of Arduino IDE, you will need to start the IDE and navigate to the Preferences menu. You can access it from the File menu in Windows or Linux, or the Arduino menu on OS X. A dialog will pop up just like the one shown below.
We will be adding a URL to the new Additional Boards Manager URLs option. The list of URLs is comma separated, and you will only have to add each URL once. New Adafruit boards and updates to existing boards will automatically be picked up by the Board Manager each time it is opened. The URLs point to index files that the Board Manager uses to build the list of available & installed boards.
Here's a short description of each of the Adafruit supplied packages that will be available in the Board Manager when you add the URL: Adafruit AVR Boards - Includes support for Flora, Gemma, Feather 32u4, Trinket, & Trinket Pro. Adafruit SAMD Boards - Includes support for Feather M0, Metro M0, Circuit Playground Express, Gemma M0 and Trinket M0 Arduino Leonardo & Micro MIDI-USB - This adds MIDI over USB support for the Flora, Feather 32u4, Micro and Leonardo using the arcore project.
Using with Arduino IDE Since the Feather/Metro/Gemma/Trinket M0 use an ATSAMD21 chip running at 48 MHz, you can pretty easily get it working with the Arduino IDE. Most libraries (including the popular ones like NeoPixels and display) will work with the M0, especially devices & sensors that use i2c or SPI. Now that you have added the appropriate URLs to the Arduino IDE preferences in the previous page, you can open the Boards Manager by navigating to the Tools->Board menu.
Install Adafruit SAMD Next you can install the Adafruit SAMD package to add the board file definitions You can type Adafruit SAMD in the top search bar, then when you see the entry, click Install © Adafruit Industries https://learn.adafruit.
Even though in theory you don't need to - I recommend rebooting the IDE Quit and reopen the Arduino IDE to ensure that all of the boards are properly installed. You should now be able to select and upload to the new boards listed in the Tools->Board menu.
Run the installer! Since we bundle the SiLabs and FTDI drivers as well, you'll need to click through the license Select which drivers you want to install, the defaults will set you up with just about every Adafruit board! © Adafruit Industries https://learn.adafruit.
Click Install to do the installin' Blink Now you can upload your first blink sketch! Plug in the Gemma M0, Trinket M0, Metro M0 or Feather M0 and wait for it to be recognized by the OS (just takes a few seconds). It will create a serial/COM port, you can now select it from the dropdown, it'll even be 'indicated' as Trinket/Gemma/Metro/Feather M0! © Adafruit Industries https://learn.adafruit.
Now load up the Blink example // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output.
Compilation Issues If you get an alert that looks like Cannot run program "{runtime.tools.arm-none-eabi-gcc.path}\bin\arm-non-eabi-g++" Make sure you have installed the Arduino SAMD boards package, you need both Arduino & Adafruit SAMD board packages © Adafruit Industries https://learn.adafruit.
Manually bootloading If you ever get in a 'weird' spot with the bootloader, or you have uploaded code that crashes and doesn't auto-reboot into the bootloader, click the RST button twice (like a double-click)to get back into the bootloader. The red LED will pulse, so you know that its in bootloader mode. Once it is in bootloader mode, you can select the newly created COM/Serial port and re-try uploading.
Ubuntu & Linux Issue Fix Note if you're using Ubuntu 15.04 (or perhaps other more recent Linux distributions) there is an issue with the modem manager service which causes the Bluefruit LE micro to be difficult to program. If you run into errors like "device or resource busy", "bad file descriptor", or "port is busy" when attempting to program then you are hitting this issue. The fix for this issue is to make sure Adafruit's custom udev rules are applied to your system.
Adapting Sketches to M0 The ATSAMD21 is a very nice little chip but its fairly new as Arduino-compatible cores go. Most sketches & libraries will work but here's a few things we noticed! The below note are for all M0 boards, but not all may apply (e.g. Trinket and Gemma M0 do not have ARef so you can skip the Analog References note!) Analog References If you'd like to use the ARef pin for a non-3.
If you have existing sketches and code and you want them to work with the M0 without a huge find-replace, put #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) // Required for Serial on Zero based boards #define Serial SERIAL_PORT_USBVIRTUAL #endif right above the first function definition in your code.
The biggest members of the SAMD21 family have five TC instances with two 'waveform output' (WO) channels, and three TCC instances with eight WO channels: TC[0-4],WO[0-1] TCC[0-2],WO[0-7] And those are the ones shown in the datasheet's multiplexer tables.
#include you'll get an error that says fatal error: util/delay.h: No such file or directory #include ^ compilation terminated. Error compiling. In which case you can simply locate where the line is (the error will give you the file name and line number) and 'wrap it' with #ifdef's so it looks like: #if !defined(ARDUINO_ARCH_SAM) && !defined(ARDUINO_ARCH_SAMD) && !defined(ESP8266) && !defin #include
byte location) will cause a Hard Fault and stop the MCU. Thankfully, there's an easy work around ... just use memcpy! uint8_t mybuffer[4]; float f; memcpy(f, mybuffer, 4) Floating Point Conversion Like the AVR Arduinos, the M0 library does not have full support for converting floating point numbers to ASCII strings. Functions like sprintf will not convert floating point. Fortunately, the standard AVR-LIBC library includes the dtostrf function which can handle the conversion for you.
simply add const before the variable name: const char str[] = "My very long string"; That string is now in FLASH. You can manipulate the string just like RAM data, the compiler will automatically read from FLASH so you dont need special progmem-knowledgeable functions. You can verify where data is stored by printing out the address: Serial.print("Address of str $"); Serial.println((int)&str, HEX); If the address is $2000000 or larger, its in SRAM.
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: Download the Adafruit nRF51 BluefruitLE library https://adafru.
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: © Adafruit Industries https://learn.adafruit.
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 © Adafruit Industries https://learn.adafruit.
// 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).
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 © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Compilation Issues If you get an alert that looks like Cannot run program "{runtime.tools.arm-none-eabi-gcc.path}\bin\arm-non-eabi-g++" Make sure you have installed the Arduino SAMD boards package, you need both Arduino & Adafruit SAMD board packages Manually bootloading If you ever get in a 'weird' spot with the bootloader, or you have uploaded code that crashes and doesn't auto-reboot into the bootloader, click the RST button twice (like a double-click)to get back into the bootloader.
You may need to go back and reselect the 'normal' USB serial port next time you want to use the normal upload. Run the sketch OK check again that the correct port is selected Then open up the Serial console. You will see the following: © Adafruit Industries https://learn.adafruit.
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 © Adafruit Industries https://learn.
© Adafruit Industries https://learn.adafruit.
OK now you know how to upload/test/communicate with your Feather M0 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 /* ...
Configuration! Before you start uploading any of the example sketches, you'll need to CONFIGURE the Bluefruit interface - there's a lot of options so pay close attention! Which board do you have? There's a few products under the Bluefruit name: If you are using the Bluefruit LE Shield then you have an SPI-connected NRF51822 module. You can use this with Atmega328 (Arduino UNO or compatible), ATmega32u4 (Arduino Leonardo, compatible) or ATSAMD21 (Arduino Zero, compatible) and possibly others.
Bluefruit LE SPI Friend If you have a stand-alone module, you have a bit of flexibility with wiring however we strongly recommend Hardware SPI, CS = 8, IRQ = 7, RST = 4 You can use this with just about any microcontroller with 5 or 6 pins Bluefruit LE UART Friend or Flora BLE If you have a stand-alone UART module you have some flexibility with wiring. However we suggest hardware UART if possible. You will likely need to use the flow control CTS pin if you are not using hardware UART.
Configure the Pins Used You'll want to check the Bluefruit Config to set up the pins you'll be using for UART or SPI Each example sketch has a secondary tab with configuration details. You'll want to edit and save the sketch to your own documents folder once set up. Common settings: You can set up how much RAM to set aside for a communication buffer and whether you want to have full debug output.
// ----------------------------------------------------------------------------------------// These settings are used in both SW UART, HW UART and SPI mode // ----------------------------------------------------------------------------------------#define BUFSIZE 128 // Size of the read buffer for incoming data #define VERBOSE_MODE true // If set to 'true' enables debug output Software UART If you are using Software UART, you can set up which pins are going to be used for RX, TX, and CTS flow control.
For both Hardware and Software SPI, you'll want to set the CS (chip select) line, IRQ (interrupt request) line and if you have a pin to spare, RST (Reset) // SHARED SPI SETTINGS #define BLUEFRUIT_SPI_CS #define BLUEFRUIT_SPI_IRQ #define BLUEFRUIT_SPI_RST 8 7 4 // Optional but recommended, set to -1 if unused Software SPI Pins If you don't have a hardware SPI port available, you can use any three pins...
For software serial (Arduino Uno, Adafruit Metro) you should uncomment the software serial contructor below, and make sure the other three options (hardware serial & SPI) are commented out. // Create the bluefruit object, either software serial...
ATCommand The ATCommand example allows you to execute AT commands from your sketch, and see the results in the Serial Monitor. This can be useful for debugging, or just testing different commands out to see how they work in the real world.
Configuration Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI If using software or hardware Serial UART: This tutorial does not need to use the MODE pin, make sure you have the mode switch © Adafruit Industries https://learn.adafruit.
in CMD mode if you do not configure & connect a MODE pin Don't forget to also connect the CTS pin on the Bluefruit to ground if you are not using it! (The Flora has this already done) Running the Sketch Once you upload the sketch to your board (via the arrow-shaped upload icon), and the upload process has finished, open up the Serial Monitor via Tools > Serial Monitor, and make sure that the baud rate in the lower right-hand corner is set to 115200: To send an AT command to the Bluefruit LE module, enter
The response to the AT command will be displayed in the main part of the Serial Monitor. The response from 'ATI' is shown below: You can do pretty much anything at this prompt, with the AT command set. Try AT+HELP to get a list of all commands, and try out ones like AT+HWGETDIETEMP (get temperature at the nRF51822 die) and AT+HWRANDOM (generate a random number) © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
BLEUart The BLEUart example sketch allows you to send and receive text data between the Arduino and a connected Bluetooth Low Energy Central device on the other end (such as you mobile phone using the Adafruit Bluefruit LE Connect application for Android or iOS in UART mode).
Configuration Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI If using software or hardware Serial UART: © Adafruit Industries https://learn.adafruit.
This tutorial does not need to use the MODE pin, make sure you have the mode switch in CMD mode if you do not configure & connect a MODE pin Don't forget to also connect the CTS pin on the Bluefruit to ground if you are not using it! (The Flora has this already done) Running the Sketch Once you upload the sketch to your board (via the arrow-shaped upload icon), and the upload process has finished, open up the Serial Monitor via Tools > Serial Monitor, and make sure that the baud rate in the lower right-han
Any text that you type in the box at the top of the Serial Monitor will be sent to the connected phone, and any data sent from the phone will be displayed in the serial monitor: You can see the incoming string here in the Adafruit Bluefruit LE Connect app below (iOS in this case): © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
The response text ('Why hello, Arduino!') can be seen below: © Adafruit Industries https://learn.adafruit.
HIDKeyboard The HIDKeyboard example shows you how you can use the built-in HID keyboard AT commands to send keyboard data to any BLE-enabled Android or iOS phone, or other device that supports BLE HID peripherals. Opening the Sketch To open the ATCommand sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select hidkeyboard: This will open up a new instance of the example in the IDE, as shown below: © Adafruit Industries https://learn.adafruit.
Configuration Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI If using software or hardware Serial UART: This tutorial does not need to use the MODE pin, make sure you have the mode switch © Adafruit Industries https://learn.adafruit.
in CMD mode! Don't forget to also connect the CTS pin on the Bluefruit to ground if you are not using it! (The Flora has this already done) Running the Sketch Once you upload the sketch to your board (via the arrow-shaped upload icon), and the upload process has finished, open up the Serial Monitor via Tools > Serial Monitor, and make sure that the baud rate in the lower right-hand corner is set to 115200: © Adafruit Industries https://learn.adafruit.
To send keyboard data, type anything into the textbox at the top of the Serial Monitor and click the Send button. Bonding the HID Keyboard Before you can use the HID keyboard, you will need to 'bond' it to your phone or PC. The bonding process establishes a permanent connection between the two devices, meaning that as soon as your phone or PC sees the Bluefruit LE module again it will automatically connect. The exact procedures for bonding the keyboard will varying from one platform to another.
Inside the Bluetooth setting panel you should see the Bluefruit LE module advertising itself as Bluefruit Keyboard under the 'Available devices' list: Tapping the device will start the bonding process, which should end with the Bluefruit Keyboard device being moved to a new 'Paired devices' list with 'Connected' written underneath the device name: © Adafruit Industries https://learn.adafruit.
To delete the bonding information, click the gear icon to the right of the device name and the click the Forget button: iOS To bond the keyboard on an iOS device, go to the Settings application on your phone, and click the Bluetooth menu item. The keyboard should appear under the OTHER DEVICES list: © Adafruit Industries https://learn.adafruit.
Once the bonding process is complete the device will be moved to the MY DEVICES category, and you can start to use the Bluefruit LE module as a keyboard: © Adafruit Industries https://learn.adafruit.
To unbond the device, click the 'info' icon and then select the Forget this Device option in the menu: OS X To bond the keyboard on an OS X device, go to the Bluetooth Preferences window and click the Pair button beside the Bluefruit Keyboard device generated by this example sketch: © Adafruit Industries https://learn.adafruit.
To unbond the device once it has been paired, click the small 'x' icon beside Bluefruit Keyboard: © Adafruit Industries https://learn.adafruit.
... and then click the Remove button when the confirmation dialogue box pops up: © Adafruit Industries https://learn.adafruit.
Controller The Controller sketch allows you to turn your BLE-enabled iOS or Android device in a handheld controller or an external data source, taking advantage of the wealth of sensors on your phone or tablet. You can take accelerometer or quaternion data from your phone, and push it out to your Arduino via BLE, or get the latest GPS co-ordinates for your device without having to purchase (or power!) any external HW.
Configuration Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI If using software or hardware Serial UART: This tutorial will also be easier to use if you wire up the MODE pin, you can use any pin but our tutorial has pin 12 by default. You can change this to any pin.
BLUEFRUIT_UART_MODE_PIN to -1 in the configuration tab so that the sketch will use the +++ method to switch between Command and Data mode! Don't forget to also connect the CTS pin on the Bluefruit to ground if you are not using it! (The Flora has this already done) Running the Sketch Once you upload the sketch to your board (via the arrow-shaped upload icon), and the upload process has finished, open up the Serial Monitor via Tools > Serial Monitor, and make sure that the baud rate in the lower right-hand
(If you're new to Bluefruit LE Connect, have a look at our dedicated Bluefruit LE Connect learning guide.) On the welcome screen, select the Adafruit Bluefruit LE device from the list of BLE devices in range: Then from the activity list select Controller: This will bring up a list of data points you can send from your phone or tablet to your Bluefruit LE module, by enabling or disabling the appropriate sensor(s). © Adafruit Industries https://learn.adafruit.
Streaming Sensor Data You can take Quaternion (absolute orientation), Accelerometer, Gyroscope, Magnetometer or GPS Location data from your phone and send it directly to your Arduino from the Controller activity. By enabling the Accelerometer field, for example, you should see accelerometer data update in the app: The data is parsed in the example sketch and output to the Serial Monitor as follows: © Adafruit Industries https://learn.adafruit.
Accel Accel Accel Accel Accel 0.20 0.22 0.25 0.21 0.27 -0.51 -0.50 -0.51 -0.47 -0.48 -0.76 -0.83 -0.83 -0.76 -0.82 Note that even though we only print 2 decimal points, the values are received from the App as a full 4-byte floating point. Control Pad Module You can also use the Control Pad Module to capture button presses and releases by selecting the appropriate menu item: © Adafruit Industries https://learn.adafruit.
This will bring up the Control Pad panel, shown below: Button presses and releases will all be logged to the Serial Monitor with the ID of the button used: Button Button Button Button 8 8 3 3 pressed released pressed released Color Picker Module You can also send RGB color data via the Color Picker module, which presents the following color selection dialogue: © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
This will give you Hexadecimal color data in the following format: RGB #A42FFF You can combine the color picker and controller sample sketches to make colorconfigurable animations triggered by buttons in the mobile app-- very handy for wearables! Download this combined sample code (configured for Feather but easy to adapt to FLORA, BLE Micro, etc.) to get started: feather_bluefruit_neopixel_animatio n_controller.zip https://adafru.it/kzF © Adafruit Industries https://learn.adafruit.
HeartRateMonitor The HeartRateMonitor example allows you to define a new GATT Service and associated GATT Characteristics, and update the characteristic values using standard AT commands. Opening the Sketch To open the ATCommand sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select heartratemonitor: This will open up a new instance of the example in the IDE, as shown below: © Adafruit Industries https://learn.adafruit.
Configuration Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI © Adafruit Industries https://learn.adafruit.
If Using Hardware or Software UART This tutorial does not need to use the MODE pin, make sure you have the mode switch in CMD mode if you do not configure & connect a MODE pin This demo uses some long data transfer strings, so we recommend defining and connecting both CTS and RTS to pins, even if you are using hardware serial.
© Adafruit Industries https://learn.adafruit.
If you open up an application on your mobile device or laptop that support the standard Heart Rate Monitor Service, you should be able to see the heart rate being updated in sync with the changes seen in the Serial Monitor: nRF Toolbox HRM Example The image below is a screenshot from the free nRF Toolbox application from Nordic on Android (also available on iOS), showing the incoming Heart Rate Monitor data: © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
CoreBluetooth HRM Example The image below is from a freely available CoreBluetooth sample application from Apple showing how to work with Bluetooth Low Energy services and characteristics: © Adafruit Industries https://learn.adafruit.
UriBeacon The UriBeacon example shows you how to use the built-in UriBeacon AT commands to configure the Bluefruit LE module as a UriBeacon advertiser, following Google's Physical Web UriBeacon specification. Opening the Sketch To open the ATCommand sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select uribeacon: This will open up a new instance of the example in the IDE, as shown below.
Configuration Check the Configuration! page earlier to set up the sketch for Software/Hardware UART or Software/Hardware SPI. The default is hardware SPI If using software or hardware Serial UART: This tutorial does not need to use the MODE pin, make sure you have the mode switch © Adafruit Industries https://learn.adafruit.
in CMD mode if you do not configure & connect a MODE pin Don't forget to also connect the CTS pin on the Bluefruit to ground if you are not using it! (The Flora has this already done) Running the Sketch Once you upload the sketch to your board (via the arrow-shaped upload icon), and the upload process has finished, open up the Serial Monitor via Tools > Serial Monitor, and make sure that the baud rate in the lower right-hand corner is set to 115200: © Adafruit Industries https://learn.adafruit.
At this point you can open the Physical Web Application for Android or for iOS, and you should see a link advertising Adafruit's website: © Adafruit Industries https://learn.adafruit.
HALP! When using the Bluefruit Micro or a Bluefruit LE with Flora/Due/Leonardo/Micro the examples dont run? We add a special line to setup() to make it so the Arduino will halt until it sees you've connected over the Serial console. This makes debugging great but makes it so you cannot run the program disconnected from a computer.
pin in the sketch Make sure you have RXI and TXO wired right! They are often swapped by accident Make sure CTS is tied to GND if you are using hardware serial and not using CTS Check the MODE red LED, is it blinking? If its blinking continuously, you might be in DFU mode, power cycle the module! If you are using Hardware Serial/Software Serial make sure you know which one and have that set up If using SPI Bluefruit: Make sure you have all 5 (or 6) wires connected properly.
AT Commands The Bluefruit LE modules use a Hayes AT-style command set to configure the device. The advantage of an AT style command set is that it's easy to use in machine to machine communication, while still being somewhat user friendly for humans. Test Command Mode '=?' 'Test' mode is used to check whether or not the specified command exists on the system or not.
AT+BLEPOWERLEVEL=-8 OK\r\n If there was a problem with the command (such as an invalid parameter) you will get an 'ERROR' response on a new line, as shown below: AT+BLEPOWERLEVEL=3 ERROR\r\n Note: This particular error was generated because '3' is not a valid value for the AT+BLEPOWERLEVEL command. Entering '-4', '0' or '4' would succeed since these are all valid values for this command.
If the command doesn't support execute mode, the response will normally be 'ERROR' on a new line. Read Command Mode '?' 'Read' mode is used to read the current value of a command.
Standard AT The following standard Hayes/AT commands are available on Bluefruit LE modules: AT Acts as a ping to check if we are in command mode. If we are in command mode, we should receive the 'OK' response. Codebase Revision: 0.3.0 Parameters: None Output: None AT OK ATI Displays basic information about the Bluefruit module. Codebase Revision: 0.3.
ATI BLEFRIEND nRF51822 QFAAG00 FB462DF92A2C8656 0.5.0 0.5.0 Feb 24 2015 S110 7.1.0, 0.0 OK Updates: Version 0.4.7+ of the firmware adds the chip revision after the chip name if it can be detected (ex. 'nRF51822 QFAAG00'). Version 0.5.0+ of the firmware adds a new 7th record containing the softdevice, softdevice version and bootloader version (ex. 'S110 7.1.0, 0.0'). ATZ Performs a system reset. Codebase Revision: 0.3.
# Disable echo support ATE=0 OK #Enable echo support ATE=1 OK +++ Dynamically switches between DATA and COMMAND mode without changing the physical CMD/UART select switch. When you are in COMMAND mode, entering '+++\n' or '+++\r\n' will cause the module to switch to DATA mode, and anything typed into the console will go direct to the BLUE UART service. To switch from DATA mode back to COMMAND mode, simply enter '+++\n' or '+++\r\n' again (be sure to include the new line character!), and a new 'OK' response
ATI BLEFRIEND nRF51822 QFAAG00 B122AAC33F3D2296 0.4.6 0.4.6 Dec 22 2014 OK +++ OK OK © Adafruit Industries https://learn.adafruit.
General Purpose The following general purpose commands are available on all Bluefruit LE modules: AT+FACTORYRESET Clears any user config data from non-volatile memory and performs a factory reset before resetting the Bluefruit module. Codebase Revision: 0.3.0 Parameters: None Output: None AT+FACTORYRESET OK As of version 0.5.0+ of the firmware, you can perform a factory reset by holding the DFU button down for 10s until the blue CONNECTED LED lights up, and then releasing the button.
AT+DFU OK AT+HELP Displays a comma-separated list of all AT parser commands available on the system. Codebase Version: 0.3.0 Parameters: None Output: A comma-separated list of all AT parser commands available on the system. The sample code below may not match future firmware releases and is provided for illustration purposes only AT+HELP AT+FACTORYRESET,AT+DFU,ATZ,ATI,ATE,AT+DBGMEMRD,AT+DBGNVMRD,AT+HWLEDPOLARITY,AT+HWLED OK AT+NVMWRITE Writes data to the 256 byte user non-volatile memory (NVM) region.
# Write 32768 as an integer starting at byte 16 in user NVM AT+NVMWRITE=16,INTEGER,32768 OK AT+NVMREAD Reads data from the 256 byte user non-volatile memory (NVM) region. Codebase Version: 0.7.0 Parameters: offset: The numeric offset for the first byte from the starting position in the user NVM size: The number of bytes to read datatype: The type used for the data being read, which is required to properly parse the data and display it as a response.
By default, '+++' is enabled locally, and disabled in BLE # Disable reomte '+++' mode switches AT+MODESWITCHEN=ble,0 OK © Adafruit Industries https://learn.adafruit.
Hardware The following commands allow you to interact with the low level HW on the Bluefruit LE module, such as reading or toggling the GPIO pins, performing an ADC conversion ,etc.: AT+BAUDRATE Changes the baud rate used by the HW UART peripheral on the nRF51822. Codebase Revision: 0.7.
AT+HWADC Performs an ADC conversion on the specified ADC pin Codebase Revision: 0.3.0 Parameters: The ADC channel (0..7) Output: The results of the ADC conversion AT+HWADC=0 178 OK AT+HWGETDIETEMP Gets the temperature in degree celcius of the BLE module's die. This can be used for debug purposes (higher die temperature generally means higher current consumption), but does not corresponds to ambient temperature and can nto be used as a replacement for a normal temperature sensor. Codebase Revision: 0.3.
pin that is set as an output: Pin numbers Pin state, where: 0 = clear the pin (logic low/GND) 1 = set the pin (logic high/VCC) INPUT MODE: To read the current state of an input pin or a pin that has been configured as an output, enter the pin number as a single parameter.
# Set pin 14 HIGH AT+HWGPIO=14,1 OK # Set pin 14 LOW AT+HWGPIO=14,0 OK # Read the current state of pin 14 AT+HWGPIO=14 0 OK # Try to update a pin that is not set as an output AT+HWGPIOMODE=14,0 OK AT+HWGPIO=14,1 ERROR AT+HWGPIOMODE This will set the mode for the specified GPIO pin (input, output, etc.). Codebase Revision: 0.3.
# Configure pin 14 as an output AT+HWGPIOMODE=14,0 OK # Get the current mode for pin 14 AT+HWPGIOMODE=14 0 OK AT+HWI2CSCAN Scans the I2C bus to try to detect any connected I2C devices, and returns the address of devices that were found during the scan process. Codebase Revision: 0.3.0 Parameters: None Output: A comma-separated list of any I2C address that were found while scanning the valid address range on the I2C bus, or nothing is no devices were found.
AT+HWVBAT 3248 OK AT+HWRANDOM Generates a random 32-bit number using the HW random number generator on the nRF51822 (based on white noise). Codebase Revision: 0.4.7 Parameters: None Output: A random 32-bit hexadecimal value (ex. '0x12345678') AT+HWRANDOM 0x769ED823 OK AT+HWMODELED Allows you to override the default behaviour of the MODE led (which indicates the operating mode by default). Codebase Revision: 0.6.
MODE LED operating mode from the fields above # Get the curent MODE LED setting AT+HWMODELED MODE OK # Change the MODE LED to indicate BLE UART activity AT+HWMODELED=BLEUART OK # Manually toggle the MODE LED AT+HWMODELED=MANUAL,TOGGLE OK AT+UARTFLOW Enables or disable hardware flow control (CTS + RTS) on the UART peripheral block of the nRF51822. Codebase Revision: 0.7.
© Adafruit Industries https://learn.adafruit.
Beacon Adafruit's Bluefruit LE modules currently support the following 'Beacon' technologies: Beacon (Apple) via AT+BLEBEACON UriBeacon (Google) via AT+BLEURIBEACON (deprecated) Eddystone (Google) via AT+EDDYSTONE* Modules can be configured to act as 'Beacons' using the following commands: AT+BLEBEACON Codebase Revision: 0.3.
AT+BLEBEACON will cause the beacon data to be stored in non-volatile config memory on the Bluefruit LE module, and these values will be persisted across system resets and power cycles. To remove or clear the beacon data you need to enter the 'AT+FACTORYRESET' command in command mode. Entering Nordic Beacon emulation using the sample code above, you can see the simulated beacon in Nordic's 'Beacon Config' tool below: © Adafruit Industries https://learn.adafruit.
AT+BLEURIBEACON Converts the specified URI into a UriBeacon advertising packet, and configures the module to advertise as a UriBeacon (part of Google's Physical Web project). To view the UriBeacon URIs you can use one of the following mobile applications: Android 4.3+: Physical Web on the Google Play Store iOS: Physical Web in Apple's App Store Codebase Revision: 0.4.7 Parameters: The URI to encode (ex. http://www.adafruit.com/blog) Output: None of a valid URI was entered (length is acceptable, etc.).
If the supplied URI is too long you will get the following output: AT+BLEURIBEACON=http://www.adafruit.com/this/uri/is/too/long URL is too long ERROR If the URI that you are trying to encode is too long, try using a shortening service like bit.ly, and encode the shortened URI. UriBeacon should be considered deprecated as a standard, and EddyStone should be used for any future development. No further development will happen in the Bluefruit LE firmware around UriBeacon.
# Enable Eddystone support AT+EDDYSTONEENABLE=1 OK # Check the current Eddystone status on the module AT+EDDYSTONEENABLE 1 OK AT+EDDYSTONEURL This command will set the URL for the Eddystone-URL protocol. Codebase Revision: 0.6.6 Parameters: The URL to encode (mandatory) An optional second parameter indicates whether to continue advertising the Eddystone URL even when the peripheral is connected to a central device Firmware 0.6.7 added an optional third parameter for the RSSI at 0 meters value.
This command should be used in combination with the Physical Web application from Google, available for Android or iOS. Run this command then select the 'Edit URL' option from the app to change the destination URL over the air. Codebase Revision: 0.6.
# Enable Eddystone service AT+EddyStonServiceEn=on OK AT+EddyStonServiceEn=1 OK # Disable Eddystone service AT+EddyStonServiceEn=off OK AT+EddyStonServiceEn=0 OK AT+EDDYSTONEBROADCAST This command can be used to start of stop advertising the Eddystone payload using the URL stored in non-volatile memory (NVM). Codebase Revision: 0.7.
# Enable broadcasting current setting of EddyStone (stored previously on nvm) AT+EddyStoneBroadcast=on OK AT+EddyStoneBroadcast=1 OK # Disable broadcasting current setting of EddyStone (still stored on nvm) AT+EddyStoneBroadcast=off OK AT+EddyStoneBroadcast=0 OK © Adafruit Industries https://learn.adafruit.
BLE Generic The following general purpose BLE commands are available on Bluefruit LE modules: AT+BLEPOWERLEVEL Gets or sets the current transmit power level for the module's radio (higher transmit power equals better range, lower transmit power equals better battery life). Codebase Revision: 0.3.
# Get the current TX power level (in dBm) AT+BLEPOWERLEVEL 0 OK # Set the TX power level to 4dBm (maximum value) AT+BLEPOWERLEVEL=4 OK # Set the TX power level to -12dBm (better battery life) AT+BLEPOWERLEVEL=-12 OK # Set the TX power level to an invalid value AT+BLEPOWERLEVEL=-3 ERROR AT+BLEGETADDRTYPE Gets the address type (for the 48-bit BLE device address).
AT+BLEGETADDR Gets the 48-bit BLE device address. Codebase Revision: 0.3.0 Parameters: None Output: The 48-bit BLE device address in the following format: 'AA:BB:CC:DD:EE:FF' AT+BLEGETADDR E4:C6:C7:31:95:11 OK AT+BLEGETPEERADDR Gets the 48-bit address of the peer (central) device we are connected to. Codebase Revision: 0.6.5 Parameters: None Output: The 48-bit address of the connected central device in hex format. The command will return ERROR if we are not connected to a central device.
Codebase Revision: 0.3.0 Parameters: None Output: The RSSI level (in dBm) if we are connected to a device, otherwise '0' # Connected to an external device AT+BLEGETRSSI -46 OK # Not connected to an external device AT+BLEGETRSSI 0 OK © Adafruit Industries https://learn.adafruit.
BLE Services The following commands allow you to interact with various GATT services present on Bluefruit LE modules when running in Command Mode. AT+BLEUARTTX This command will transmit the specified text message out via the UART Service while you are running in Command Mode. Codebase Revision: 0.3.0 Parameters: The message payload to transmit. The payload can be up to 240 characters (since AT command strings are limited to a maximum of 256 bytes total).
back-slash for the escape code to arrive as-intended in the AT command. For example: ble.println("AT+BLEUARTTX=Some Test\\r\\n"); You must be connected to another device for this command to execute # Send a string when connected to another device AT+BLEUARTTX=THIS IS A TEST OK # Send a string when not connected AT+BLEUARTTX=THIS IS A TEST ERROR TX FIFO Buffer Handling Starting with firmware version 0.6.
Note: The TX FIFO full check will happen for each GATT transaction (of up to 20 bytes of data each), so large data transfers may have multiple 200ms wait states. You can use the AT+BLEUARTFIFO=TX command to check the size of the TX FIFO before sending data to ensure that you have enough free space available in the buffer. The TX FIFO has the following size, depending on the firmware version used: Firmware <=0.6.6: 160 characters wide Firmware >=0.6.
TX FIFO size before sending data, which you can do using the AT+BLEUARTFIFO command. If not enough space is available for the entire payload, add a SW delay until enough space is available. Any single AT+BLEUARTTX command can fit into the FIFO, but multiple large instances of this command may cause the FIFO to fill up mid transfer. AT+BLEUARTTXF This is a convenience function the serves the same purpose as AT+BLEUARTTX, but data is immediately sent in a single BLE packet ('F' for force packet).
# Command results when data is available AT+BLEUARTRX Sent from Android OK # Command results when no data is available AT+BLEUARTRX OK AT+BLEUARTFIFO This command will return the free space available in the BLE UART TX and RX FIFOs. If you are transmitting large chunks of data, you may want to check if you have enough free space in the TX FIFO before sending, keeping in mind that individual GATT packets can contain up to 20 user bytes each. Codebase Revision: 0.6.
emulate a keyboard on supported iOS and Android devices. By default HID keyboard support is disabled, so you need to set BLEKEYBOARDEN to 1 and then perform a system reset before the keyboard will be enumerated and appear in the Bluetooth preferences on your phone, where if can be bonded as a BLE keyboard. Codebase Revision: 0.5.0 Parameters: 1 or 0 (1 = enable, 0 = disable) Output: None As of firmware version 0.6.
\r - Carriage Return \n - Line Feed \b - Backspace \t - Tab \\ - Backslash As of version 0.6.7 you can also use the following escape code when sending a single character ('AT+BLEKEYBOARD=?' has another meaning for the AT parser): \? - Question mark Codebase Revision: 0.5.0 Parameters: The text string (optionally including escape characters) to transmit Output: None # Send a URI with a new line ending to execute in Chrome, etc. AT+BLEKEYBOARD=http://www.adafruit.com\r\n OK # Send a single question mark (spec
indicate the keys were released! Modifier Values The modifier byte can have one or more of the following bits set: Bit 0 (0x01): Left Control Bit 1 (0x02): Left Shift Bit 2 (0x04): Left Alt Bit 3 (0x08): Left Window Bit 4 (0x10): Right Control Bit 5 (0x20): Right Shift Bit 6 (0x40): Right Alt Bit 7 (0x80): Right Window Codebase Revision: 0.5.0 Parameters: A set of hexadecimal values separated by a hyphen ('-').
keyboard, mouse or media controll on supported iOS, Android, OSX and Windows 10 devices. By default HID support is disabled, so you need to set BLEHIDEN to 1 and then perform a system reset before the HID devices will be enumerated and appear in on your central device. Codebase Revision: 0.6.
# Move the mouse 100 ticks right and 100 ticks down AT+BLEHIDMOUSEMOVE=100,100 OK # Scroll down 20 pixels or lines (depending on context) AT+BLEHIDMOUSEMOVE=,,20, OK # Pan (horizontal scroll) to the right (exact behaviour depends on OS) AT+BLEHIDMOUSEMOVE=0,0,0,100 AT+BLEHIDMOUSEBUTTON Manipulates the HID mouse buttons via the specific string(s). Codebase Revision: 0.6.
# Double click the left mouse button AT+BLEHIDMOUSEBUTTON=L,doubleclick OK # Press the left mouse button down, move the mouse, then release L # This is required to perform 'drag' then stop type operations AT+BLEHIDMOUSEBUTTON=L OK AT+BLEHIDMOUSEMOVE=-100,50 OK AT+BLEHIDMOUSEBUTTON=0 OK # Hold the backward mouse button for 200 milliseconds (OS dependent) AT+BLEHIDMOUSEBUTTON=B,hold,200 OK AT+BLEHIDCONTROLKEY Sends HID media control commands for the bonded device (adjust volume, screen brightness, song selec
MUTE BASS TREBLE BASS_BOOST VOLUME+ VOLUMEBASS+ BASSTREBLE+ TREBLEApplication Launchers (Windows 10 only so far) EMAILREADER CALCULATOR FILEBROWSER Browser/File Explorer Controls (Firefox on Windows/Android only) SEARCH HOME BACK FORWARD STOP REFRESH BOOKMARKS You can also send a raw 16-bit hexadecimal value in the '0xABCD' format. A full list of 16-bit 'HID Consumer Control Key Codes' can be found here (see section 12). Output: Normally none.
# Toggle the sound on the bonded central device AT+BLEHIDCONTROLKEY=MUTE OK # Hold the VOLUME+ key for 500ms AT+BLEHIDCONTROLKEY=VOLUME+,500 OK # Send a raw 16-bit Consumer Key Code (0x006F = Brightness+) AT+BLEHIDCONTROLKEY=0x006F OK AT+BLEHIDGAMEPADEN Enables HID gamepad support in the HID service. By default the gamepad is disabled as of version 0.7.6 of the firmware since it causes problems on iOS and OS X and should only be used on Android and Windows based devices. Codebase Revision: 0.7.
x: LEFT, RIGHT: If X=-1 then 'LEFT' is pressed, if X=1 then 'RIGHT' is pressed, if X=0 then neither left nor right are pressed y: UP, DOWN: If Y=-1 then 'UP' is pressed, if Y=1 then 'DOWN' is pressed, if Y=0 then neither up nor down are pressed buttons: 0x00-0xFF, which is a bit mask for 8 button 0-7 Output: Nothing HID gamepad is disabled by default as of version 0.7.6, and must first be enabled via AT+BLEHIDGAMEPADEN=1 before it can be used.
Note: This command will require a reset to take effect. # Check the current state of the MIDI service AT+BLEMIDIEN 1 OK # Enable the MIDI Service AT+BLEMIDIEN=1 OK AT+BLEMIDIRX Reads an incoming MIDI character array from the buffer. Codebase Revision: 0.7.0 Parameters: None Output: The midi event in byte array format AT+BLEMIDIRX 90-3C-7F OK AT+BLEMIDITX Sends a MIDI event to host. Codebase Revision: 0.7.
# Send 1 event (middle C with max velocity) AT+BLEMIDITX=90-3C-7F OK # Send 2 events AT+BLEMIDITX=90-3C-7F-A0-3C-7F OK # Send 1 full event + running event AT+BLEMIDITX=90-3C-7F-3C-7F OK AT+BLEBATTEN Enables the Battery Service following the definition from the Bluetooth SIG. Codebase Revision: 0.7.
Parameters: The percentage for the battery in the range of 0..100. Output: If executed with no parameters, the current battery level stored in the characteristic. # Set the battery level to 72% AT+BLEBATTVAL=72 OK © Adafruit Industries https://learn.adafruit.
BLE GAP GAP, which stands for the Generic Access Profile, governs advertising and connections with Bluetooth Low Energy devices. The following commands can be used to configure the GAP settings on the BLE module. You can use these commands to modify the advertising data (for ex. the device name that appears during the advertising process), to retrieve information about the connection that has been established between two devices, or the disconnect if you no longer wish to maintain a connection.
Codebase Revision: 0.3.0 Parameters: None Output: 1 if we are connected, otherwise 0 # Connected AT+GAPGETCONN 1 OK # Not connected AT+GAPGETCONN 0 OK AT+GAPDISCONNECT Disconnects to the external device if we are currently connected. Codebase Revision: 0.3.0 Parameters: None Output: None AT+GAPDISCONNECT OK AT+GAPDEVNAME Gets or sets the device name, which is included in the advertising payload for the Bluefruit LE module Codebase Revision: 0.3.
Output: The device name if the command is executed in read mode Updating the device name will persist the new value to non-volatile memory, and the updated name will be used when the device is reset. To reset the device to factory settings and clean the config data from memory run the AT+FACTORYRESET command.
Codebase Revision: 0.3.0 Parameters: If updating the GAP intervals, the following comma-separated values can be entered: Minimum connection interval (in milliseconds) Maximum connection interval (in milliseconds) Fast Advertising interval (in milliseconds) Fast Advertising timeout (in seconds) >= 0.7.0: Low power advertising interval (in milliseconds), default = 417.5 ms To save power, the Bluefruit modules automatically drop to a lower advertising rate after 'fast advertising timeout' seconds.
Updating the GAP intervals will persist the new values to non-volatile memory, and the updated values will be used when the device is reset. To reset the device to factory settings and clean the config data from memory run the AT+FACTORYRESET command.
AT+GAPSTOPADV Stops advertising packets from being transmitted by the Bluefruit LE module. Codebase Revision: 0.3.0 Parameters: None Output: None AT+GAPSTOPADV OK AT+GAPSETADVDATA Sets the raw advertising data payload to the specified byte array (overriding the normal advertising data), following the guidelines in the Bluetooth 4.0 or 4.1 Core Specification. In particular, Core Specification Supplement (CSS) v4 contains the details on common advertising data fields like 'Flags' (Part A, Section 1.
For example, to insert the 'Flags' Data Type (Data Type Value 0x01), and set the value to 0x06/0b00000110 (BR/EDR Not Supported and LE General Discoverable Mode) we would use the following byte array: 02-01-06 0x02 indicates the number of bytes in the entry 0x01 is the 'Data Type Value' and indicates that this is a 'Flag' 0x06 (0b00000110) is the Flag value, and asserts the following fields (see Core Specification 4.0, Volume 3, Part C, 18.1): LE General Discoverable Mode (i.e.
the advertising packet, being careful to stay within the space limits defined by the Bluetooth Core Specification. Response: None # Advertise as Discoverable and BLE only with 16-bit UUIDs 0x180D and 0x180A AT+GAPSETADVDATA=02-01-06-05-02-0d-18-0a-18 OK The results of this command can be seen in the screenshot below, taken from a sniffer analyzing the advertising packets in Wireshark.
BLE GATT GATT, which standards for the Generic ATTribute Profile, governs data organization and data exchanges between connected devices. One device (the peripheral) acts as a GATT Server, which stores data in Attribute records, and the second device in the connection (the central) acts as a GATT Client, requesting data from the server whenever necessary. The following commands can be used to create custom GATT services and characteristics on the BLEFriend, which are used to store and exchange data.
Response: None AT+GATTCLEAR OK AT+GATTADDSERVICE Adds a new custom service definition to the device. Codebase Revision: 0.3.0 Parameters: This command accepts a set of comma-separated key-value pairs that are used to define the service properties. The following key-value pairs can be used: UUID: The 16-bit UUID to use for this service. 16-bit values should be in hexadecimal format (0x1234). UUID128: The 128-bit UUID to use for this service.
# Clear any previous custom services/characteristics AT+GATTCLEAR OK # Add a battery service (UUID = 0x180F) to the peripheral AT+GATTADDSERVICE=UUID=0x180F 1 OK # Add a battery measurement characteristic (UUID = 0x2A19), notify enabled AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100 1 OK # Clear any previous custom services/characteristics AT+GATTCLEAR OK # Add a custom service to the peripheral AT+GATTADDSERVICE=UUID128=00-11-00-11-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF 1 OK # Add a custom ch
description. Codebase Revision: 0.3.0 Parameters: This command accepts a set of comma-separated key-value pairs that are used to define the characteristic properties. The following key-value pais can be used: UUID: The 16-bit UUID to use for the characteristic (which will be insert in the 3rd and 4th bytes of the parent services 128-bit UUID). This value should be entered in hexadecimal format (ex. 'UUID=0x1234').
Response: The index value of the characteristic in the custom GATT characteristic lookup table. (It's important to keep track of these characteristic index values to work with the characteristic later.
Version 0.6.6 of the Bluefruit LE firmware added the ability to use a new 'UUID128' flag to add custom 128-bit UUIDs that aren't related to the parent service UUID (which is used when passing the 16-bit 'UUID' flag). To specify a 128-bit UUID for your customer characteristic, enter a value resembling the following syntax: # Add a custom characteristic to the above service using a # custom 128-bit UUID AT+GATTADDCHAR=UUID128=00-11-22-33-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF,PROPERTIES 1 OK Version 0.7.
Namespace = Bluetooth SIG Assigned Number (0x01) Description = None (0x0000) The results from Nordic's Master Control Panel app can be seen below: AT+GATTCHAR Gets or sets the value of the specified custom GATT characteristic (based on the index ID returned when the characteristic was added to the system via AT+GATTADDCHAR). Codebase Revision: 0.3.0 Parameters: This function takes one or two comma-separated functions (one parameter = read, two parameters = write).
# Clear any previous custom services/characteristics AT+GATTCLEAR OK # Add a battery service (UUID = 0x180F) to the peripheral AT+GATTADDSERVICE=UUID=0x180F 1 OK # Add a battery measurement characteristic (UUID = 0x2A19), notify enabled AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100 1 OK # Read the battery measurement characteristic (index ID = 1) AT+GATTCHAR=1 0x64 OK # Update the battery measurement characteristic to 32 (hex 0x20) AT+GATTCHAR=1,32 OK # Verify the previous write attempt AT+
# Clear any previous custom services/characteristics AT+GATTCLEAR OK # Add a battery service (UUID = 0x180F) to the peripheral AT+GATTADDSERVICE=UUID=0x180F 1 OK # Add a battery measurement characteristic (UUID = 0x2A19), notify enabled AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100 1 OK # Add a custom service to the peripheral AT+GATTADDSERVICE=UUID128=00-11-00-11-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF 2 OK # Add a custom characteristic to the above service (making sure that there # is no conf
Note: This is a specialized command and no NEWLINE is present at the end of the command! © Adafruit Industries https://learn.adafruit.
Debug The following debug commands are available on Bluefruit LE modules: Use these commands with care since they can easily lead to a HardFault error on the ARM core, which will cause the device to stop responding. AT+DBGMEMRD Displays the raw memory contents at the specified address. Codebase Revision: 0.3.
AT+DBGNVMRD Displays the raw contents of the config data section of non-volatile memory Codebase Revision: 0.3.0 Properties: None Output: The raw config data from non-volatile memory AT+DBGNVMRD FE CA 38 05 00 03 00 00 01 12 01 00 55 41 52 54 00 00 00 00 00 00 00 00 00 00 00 OK AT+DBGSTACKSIZE Returns the current stack size, to help detect stack overflow or detect stack memory usage when optimising memory usage on the system. Codebase Revision: 0.4.
Output: The memory contents of the entire stack region AT+DBGSTACKDUMP 0x20003800: CAFEF00D 0x20003810: CAFEF00D 0x20003820: CAFEF00D 0x20003830: CAFEF00D 0x20003840: CAFEF00D 0x20003850: CAFEF00D 0x20003860: CAFEF00D 0x20003870: CAFEF00D 0x20003880: CAFEF00D 0x20003890: CAFEF00D 0x200038A0: CAFEF00D 0x200038B0: CAFEF00D 0x200038C0: CAFEF00D 0x200038D0: CAFEF00D 0x200038E0: CAFEF00D 0x200038F0: CAFEF00D 0x20003900: CAFEF00D 0x20003910: CAFEF00D 0x20003920: CAFEF00D 0x20003930: CAFEF00D 0x20003940: CAFEF00D
0x20003AA0: 0x20003AB0: 0x20003AC0: 0x20003AD0: 0x20003AE0: 0x20003AF0: 0x20003B00: 0x20003B10: 0x20003B20: 0x20003B30: 0x20003B40: 0x20003B50: 0x20003B60: 0x20003B70: 0x20003B80: 0x20003B90: 0x20003BA0: 0x20003BB0: 0x20003BC0: 0x20003BD0: 0x20003BE0: 0x20003BF0: 0x20003C00: 0x20003C10: 0x20003C20: 0x20003C30: 0x20003C40: 0x20003C50: 0x20003C60: 0x20003C70: 0x20003C80: 0x20003C90: 0x20003CA0: 0x20003CB0: 0x20003CC0: 0x20003CD0: 0x20003CE0: 0x20003CF0: 0x20003D00: 0x20003D10: 0x20003D20: 0x20003D30: 0x20003D
0x20003D90: 0x20003DA0: 0x20003DB0: 0x20003DC0: 0x20003DD0: 0x20003DE0: 0x20003DF0: 0x20003E00: 0x20003E10: 0x20003E20: 0x20003E30: 0x20003E40: 0x20003E50: 0x20003E60: 0x20003E70: 0x20003E80: 0x20003E90: 0x20003EA0: 0x20003EB0: 0x20003EC0: 0x20003ED0: 0x20003EE0: 0x20003EF0: 0x20003F00: 0x20003F10: 0x20003F20: 0x20003F30: 0x20003F40: 0x20003F50: 0x20003F60: 0x20003F70: 0x20003F80: 0x20003F90: 0x20003FA0: 0x20003FB0: 0x20003FC0: 0x20003FD0: 0x20003FE0: 0x20003FF0: OK 000080E8 622C8000 40011000 00000000 6278
History This page tracks additions or changes to the AT command set based on the firmware version number (which you can obtain via the 'ATI' command): Version 0.7.7 The following AT commands and features were added in the 0.7.7 release: Added AT+BLEUARTTXF (F for force) to immediately send the specified data out in an BLE UART packet (max 20 bytes), bypassing any FIFO delays and avoiding packets potentially being transmitted in two transactions.
Send a MIDI event AT+BLEMIDIRX Receive an available MIDI event AT+GATTCHARRAW Added this read only command to read binary (instead of ASCII) data from a characteristic. It is non-printable but less overhead and easier for writing library in Arduino AT+NVMWRITE=offset,datatype,data Writes data to 256 byte user NVM.
AT+GAPINTERVALS Added a new 'adv_lowpower_interval' parameter, default value is 417.5 ms.
The following commands were changed in the 0.6.7 release: AT+BLEUARTTX If the TX FIFO is full, the command will wait up to 200ms to see if the FIFO size decreases before exiting and returning an ERROR response due to the FIFO being full. AT+BLEURIBEACON This command will go back to using the old (deprecated) UriBeacon UUID (0xFED8), and only the AT+EDDYSTONEURL command will use the newer Eddystone UUID (0xFEAA). AT+BLEKEYBOARD and AT+BLEUARTTX These commands now accept '\?' as an escape code since 'AT+BLEKE
AT+HWMODELED Allows the user to override the default MODE LED behaviour with one of the following options: DISABLE, MODE, HWUART, BLEUART, SPI, MANUAL AT+BLECONTROLKEY Allows HID media control values to be sent to a bonded central device (volume, screen brightness, etc.
Fixed a bug with AT+GATTCHAR max_len value not being taken into account after a reset (min_len was always used when repopulating the value) Version 0.6.2 This is the first release targetting 32KB SRAM parts (QFAC). 16KB SRAM parts can't be used with this firmware due to memory management issues, and should use the earlier 0.5.0 firmware. The following AT commands were changed in the 0.6.
+++ AT+HWRANDOM AT+BLEURIBEACON AT+DBGSTACKSIZE AT+DBGSTACKDUMP The following commands were changed in the 0.4.7 release: ATI The chip revision was added after the chip name. Whereas ATI would previously report 'nRF51822', it will now add the specific HW revision if it can be detected (ex 'nRF51822 QFAAG00') Version 0.3.0 First public release © Adafruit Industries https://learn.adafruit.
Command Examples The following code snippets can be used when operating in Command Mode to perform specific tasks.
Python Script The following code performs the same function, but has been placed inside a Python wrapper using PySerial to show how you can script actions for the AT parser. import io import sys import serial import random from time import sleep filename = "hrm.py" ser = None serio = None verbose = True # Set this to True to see all of the incoming serial data def usage(): """Displays information on the command-line parameters for this script""" print "Usage: " + filename + " \n" print "For exa
def atcommand(command, delayms=0): """Executes the supplied AT command and waits for a valid response""" serio.write(unicode(command + "\n")) if delayms: sleep(delayms/1000) rx = None while rx != "OK\r\n" and rx != "ERROR\r\n": rx = serio.readline(2000) if verbose: print unicode(rx.rstrip("\r\n")) # Check the return value if rx == "ERROR\r\n": raise ValueError("AT Parser reported an error on '" + command.
The results of this script can be seen below in the 'HRM' app of Nordic's nRF Toolbox application: Please note that nRF Toolbox will only display HRM data if the value changes, so you will need to update the Heart Rate Measurement characteristic at least once after opening the HRM app and connecting to the BLEFriend © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
SDEP (SPI Data Transport) In order to facilitate switching between UART and SPI based Bluefruit LE modules, the Bluefruit LE SPI Friend and Shield uses the same AT command set at the UART modules ( ATI , AT+HELP , etc.). These text-based AT commands are encoded as binary messages using a simple binary protocol we've named SDEP (Simple Data Exhange Protocol).
packets (of up to 20 bytes each). The SPI commands must be setup to transmit MSB (most significant bit) first (not LSB first) IRQ Pin The IRQ line is asserted by the Bluefruit LE SPI Friend/Shield as long as an entire SDEP packet is available in the buffer on the nRF51822, at which point you should read the packet, keeping the CS line asserted for the entire transaction (as detailed above).
SDEP (Simple Data Exchange Protocol) The Simple Data Exchange Protocol (SDEP) can be used to send and receive binary messages between two connected devices using any binary serial bus (USB HID, USB Bulk, SPI, I2C, Wireless, etc.), exchanging data using one of four distinct message types (Command, Response, Alert and Error messages).
Either connected device can initiate SDEP transactions, though certain transport protocols imposes restrictions on who can initiate a transfer. The master device, for example, always initiates transactions with Bluetooth Low Energy or USB, meaning that slave devices can only reply to incoming commands. Every device that receives a Command Message must reply with a Response Message, Error Message or Alert message.
10 34 12 01 FF 0: Message Type (U8) 0x10 1+2: Command ID (U16) 0x34 0x12 3: Payload Len (U8) 0x01 4: Payload (...) 0xFF The first byte is the Message Type (0x10), which identifies this as a command message. The second and third bytes are 0x1234 (34 12 in little-endian notation), which is the unique command ID. This value will be compared against the command lookup table and redirected to an appropriate command handler function if a matching entry was found.
Command ID field should always be present. A long response (>16 bytes payload) must be divided into multiple packets. Similar to long commands, the More data field (bit 7 of byte 3) is used to indicate whether additional packets are available for the same response. On responses that span more than one packet, the More data bit on the final packet will be set to 0 to indicate that this is the last packet in the sequence. The SDEP receiver must re-assemble all sub-packets in into one payload when necessary.
Name Type Meaning Message Type U8 Always '0x40' Alert ID U16 Unique ID for the Alert Condition Payload Length U8 Payload Length (0..16) Payload ... Optional response payload A sample alert message would be: 40 CD AB 04 42 07 00 10 0: Message Type (U8) 0x40 1+2: Alert ID (U16) 0xCD 0xAB 3: Payload Length 0x04 4+5+6+7: Payload 0x42 0x07 0x00 0x10 The first byte is the Message Type (0x40), which identifies this as an alert message.
ID Alert Description 0x0000 Reserved Reserved for future use 0x0001 System Reset The system is about to reset 0x0002 Battery Low The battery level is low 0x0003 Battery Critical The battery level is critically low Error Messages Error messages (Message Type = 0x80) are returned whenever an error condition is present on the system, and have the following structure: Name Type Meaning Message Type U8 Always '0x80' Error ID U16 Unique ID for the error condition Reserved U8 Reserved for
ID Error Description 0x0000 Reserved Reserved for future use 0x0001 Invalid CMD ID CMD ID wasn't found in the lookup table 0x0003 Invalid Payload The message payload was invalid Existing Commands At present, there are only four SDEP commands implemented in the Bluefruit SPIFRIEND32 firmware: SDEP_CMDTYPE_INITIALIZE = 0xBEEF SDEP_CMDTYPE_AT_WRAPPER = 0x0A00 SDEP_CMDTYPE_BLE_UARTTX = 0x0A01 SDEP_CMDTYPE_BLE_UARTRX = 0x0A02 SDEP_CMDTYPE_INITIALIZE can be used to reset the SDEP system when a HW RST
This will cause the ATI command to be executed, which will return basic system information. © Adafruit Industries https://learn.adafruit.
GATT Service Details Data in Bluetooth Low Energy is organized around units called 'GATT Services' and 'GATT Characteristics'. To expose data to another device, you must instantiate at least one service on your device. Adafruit's Bluefruit LE Pro modules support some 'standard' services, described below (more may be added in the future).
UART Service Base UUID: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E This service simulates a basic UART connection over two lines, TXD and RXD. It is based on a proprietary UART service specification by Nordic Semiconductors. Data sent to and from this service can be viewed using the nRFUART apps from Nordic Semiconductors for Android and iOS. This service is available on every Bluefruit LE module and is automatically started during the power-up sequence.
Software Resources To help you get your Bluefruit LE module talking to other Central devices, we've put together a number of open source tools for most of the major platforms supporting Bluetooth Low Energy.
Version 2.x source code: https://github.com/adafruit/Bluefruit_LE_Connect_v2 Version 2.x of the app is a complete rewrite that includes iOS, OS X GUI and OS X command-line tools in a single codebase. Bluefruit LE Connect for OS X (Swift) This OS X desktop application is based on the same V2.x codebase as the iOS app, and gives you access to BLE UART, basic Pin I/O and OTA DFU firmware updates from the convenience of your laptop or mac.
Bluefruit LE Command Line Updater for OS X (Swift) This experimental command line tool is unsupported and provided purely as a proof of concept, but can be used to allow firmware updates for Bluefruit devices from the command line.
$ ./bluefruit bluefruit v0.3 Usage: bluefruit [options...] Commands: Scan peripherals: Automatic update: Custom firmware: Show this screen: Show version: Options: --uuid --enable-beta scan update [--enable-beta] [--uuid ] dfu --hex [--init ] [--uuid ] --help --version If present the peripheral with that uuid is used.
ABLE (Cross Platform/Node+Electron) ABLE (Adafruit Bluefruit LE Desktop) is a cross-platform desktop application based on Sandeep Misty's noble library and the Electron project from Github (used by Atom). It runs on OS X, Windows 7+ and select flavours of Linux (Ubuntu tested locally). Windows 7 support is particularly interesting since Windows 7 has no native support for Bluetooth Low Energy but the noble library talks directly to supported Bluetooth 4.
Bluefruit LE Python Wrapper As a proof of concept, we've played around a bit with getting Python working with the native Bluetooth APIs on OS X and the latest version of Bluez on certain Linux targets. There are currently example sketches showing how to retreive BLE UART data as well as some basic details from the Device Information Service (DIS).
These debug tools are provided purely as a convenience for advanced users for device recovery purposes, and are not recommended unless you're OK with potentially bricking your board. Use them at your own risk. AdaLink (Python) This command line tool is a python-based wrapper for programming ARM MCUs using either a Segger J-Link or an STLink/V2. You can use it to reflash your Bluefruit LE module using the latest firmware from the Bluefruit LE firmware repo.
different firmware releases when debugging. It relies on AdaLink or OpenOCD beneath the surface (see above), but you can use this command line tool to flash your nRF51822 with a specific SoftDevice, Bootloader and Bluefruit firmware combination. It currently supports using either a Segger J-Link or STLink/V2 via AdaLink, or GPIO on a Raspberry Pi if you don't have access to a traditional ARM SWD debugger.
BLE FAQ Can I talk to Classic Bluetooth devices with a Bluefruit LE modules? No. Bluetooth Low Energy and 'Classic' Bluetooth are both part of the same Bluetooth Core Specification -- defined and maintained by the Bluetooth SIG -- but they are completely different protocols operating with different physical constraints and requirements. The two protocols can't talk to each other directly.
The reason behind the need for CTS and RTS is that the UART block on the nRF51822 isn't very robust, and early versions of the chip had an extremely small FIFO meaning that the UART peripheral was quickly overwhelmed. Using CTS and RTS significantly improves the reliability of the UART connection since these two pins tell the device on the other end when they need to wait while the existing buffered data is processed. To enable CTS and RTS support, go into the BluefruitConfig.
First, try a factory reset by holding down the DFU button for about 10 seconds until the CONN LED starts flashing, then release the DFU button to perform a factory reset.
Click the Upload button, which should now be enabled on the home screen This will begin the DFU update process which should cause the firmware to be updated or restored on your Bluefruit LE module On iOS: Create a .zip file containing the .hex file and init.dat file that you will use for the firmware update. For example: Rename 'blefriend32_s110_xxac_0_6_7_150917_blefriend32.hex' to application.hex Rename 'blefriend32_s110_xxac_0_6_7_150917_blefriend32_init.dat' to application.dat Upload the .
provides a bootloader with fail safe features that prevents you from ever bricking boards via OTA updates. AdaLink (SWD/JTAG Debugger Wrapper) Transitioning between the two board types (sniffer and Bluefruit LE module) is unfortunately not a risk-free operation, and requires external hardware, software and know-how to get right, which is why it isn't covered by our support team. That said ...
to optionally update your Bluefruit LE modules with pre-release or BETA firmware. This functionality is primarilly provided as a debug and testing mechanism for support issues in the forum, and should only be used when trying to identify and resolve specific issues with your modules! Enabling BETA Releases on iOS Make sure you have at least version 1.7.
iPhone 5/6 + IOS 8.0/8.1 6 packets * 20 bytes * 1/0.030 s = 4 kB/s = 32 kbps iPhone 5/6 + IOS 8.2/8.3 3 packets * 20 bytes * 1/0.030 s = 2 kB/s = 16 kbps iPhone 5/6 + IOS 8.x with nRF8001 1 packet * 20 bytes * 1/0.030 s = 0.67 kB/s = 5.3 kbps Nexus 4 4 packets * 20 bytes * 1/0.0075 s = 10.6 kB/s = 84 kbps Nordic Master Emulator Firmware (MEFW) with nRF51822 0.9.0 1 packet * 20 bytes * 1/0.0075 = 2.67 kB/s = 21.33 kbps Nordic Master Emulator Firmware (MEFW) with nRF51822 0.11.0 6 packets * 20 bytes * 1/0.
orientation, RSSI will fall. You can read the RSSI value between two connected devices with the AT+BLEGETRSSI command, but there are no meaningful and repeatable conclusions that can be drawn from this value about distance other than perhaps 'farther' or 'closer' in a very loose sense of the terms.
# Initialise the USB dongle $ sudo hciconfig hci0 up # Scan for the UART BLE device $ sudo hcitool lescan D6:4E:06:4F:72:86 UART # Start gatttool, pointing to the UART device found above $ sudo gatttool -b D6:4E:06:4F:72:86 -I -t random --sec-level=high [D6:4E:06:4F:72:86][LE]> connect Attempting to connect to D6:4E:06:4F:72:86 Connection successful # Scan for primary GATT Services [D6:4E:06:4F:72:86][LE]> primary attr handle: 0x0001, end grp handle: attr handle: 0x0008, end grp handle: attr handle: 0x0009,
handle: 0x000e # # # # # value: 00 00 Enable notifications on the RX characteristic (CCCD handle = 0x000e) 0100 = get notifications 0200 = get indications 0300 = get notifications + indications 0000 = disable notifications + indications [D6:4E:06:4F:72:86][LE]> char-write-req 0x000e 0100 Characteristic value was written successfully # Just to make sure it was updated [D6:4E:06:4F:72:86][LE]> char-read-hnd 0x000e Characteristic value/descriptor: 01 00 # Writing "test" in the Serial Monitor of the Arduino
No, on SPI-based boards the IRQ pin is used to indicate that an SDEP response is available to an SDEP command. For example, when you sent the `AT+BLEUARTRX` command as an SDEP message, the Bluefruit firmware running on the nRF51822 will parse the message, prepare an SDEP response, and trigger the IRQ pin to tell the MCU that the response is ready. This is completely independant from the BLE UART service, which doesn't have interrupt capability at present. © Adafruit Industries https://learn.adafruit.
DFU Bluefruit Updates For videos on the latest update procedure using Bluefruit LE Connect see: iOS: https://learn.adafruit.com/introducing-adafruit-ble-bluetooth-low-energy-friend/dfuon-ios Android: https://learn.adafruit.com/introducing-adafruit-ble-bluetooth-low-energyfriend/dfu-on-android-4-dot-3-plus The video below is out of date and applies to early versions of the board before the Bluefruit LE Connect apps were available for iOS, Android and OS X in the respective app stores.
Downloads MDBT Datasheet PCB Eagle CAD Files on GitHub Fritzing object available in the Adafruit Fritzing Library Feather M0 Bluefruit pinout diagram https://adafru.it/z3A Datasheets ATSAMD21 Datasheet (the main chip on the Feather M0) Schematic Click to enlarge Fab Print © Adafruit Industries https://learn.adafruit.
Dimensions in Inches © Adafruit Industries https://learn.adafruit.
Device Recovery Sometimes, bad things unfortunately happen. Thankfully, 99% of the time it's purely a SW issue and the Bluefruit devices have a robust bootloader with some fail safes that can almost always recover your device. How to Recover a Bluefruit Board 1. Force DFU Mode at Startup The first step is to force your board into a special bootloader mode, which will prevent any faulty user sketches or corrupted config data from causing problems.
Bluefruit UART Friend V2 Bluefruit LE UART Friend BLESPIFRIEND Firmware (SPI) Bluefruit LE SPI Friend Bluefruit LE Shield Bluefruit LE Micro Feather 32u4 Bluefruit LE Feather M0 Bluefruit LE 3. Flash a Test Sketch Once the core Bluefruit firmware has been updated, flash a test sketch to the device from the Arduino IDE, such as the following blinky code: // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output.
This will cause a factory reset which will wipe all config data, and should restore your board, getting you back to a normal state in most situations! Still Having Problems? Hop on over to our support forums clearly explaining your problem along with the following information, and, we'll be happy to help: You product name and ideally the product ID The Bluefruit firmware version you are using (available at the top of the Serial Monitor output on most example sketches) The Operating System your are using Th
Feather HELP! My Feather stopped working when I unplugged the USB! A lot of our example sketches have a while (!Serial); line in setup(), to keep the board waiting until the USB is opened. This makes it a lot easier to debug a program because you get to see all the USB data output.
9. The IDE should see the bootloader COM/Serial port and upload properly I can't get the Feather USB device to show up - I get "USB Device Malfunctioning" errors! This seems to happen when people select the wrong board from the Arduino Boards menu. If you have a Feather 32u4 (look on the board to read what it is you have) Make sure you © Adafruit Industries https://learn.adafruit.
select Feather 32u4 for ATMega32u4 based boards! Do not use anything else, do not use the 32u4 breakout board line. If you have a Feather M0 (look on the board to read what it is you have) Make sure you select Feather M0 - do not use 32u4 or Arduino Zero I'm having problems with COM ports and my Feather 32u4/M0 Theres two COM ports you can have with the 32u4/M0, one is the user port and one is the bootloader port.
I'm trying to upload to my Feather M0, and I get this error "Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding" You probably don't have Feather M0 selected in the boards drop-down. Make sure you selected Feather M0. I'm trying to upload to my Feather and i get this error "avrdude: ser_recv(): programmer is not responding" You probably don't have Feather M0 / Feather 32u4 selected in the boards drop-down. Make sure you selected Feather M0 (or Feather 32u4).