0
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心
发布
  • 发文章

  • 发资料

  • 发帖

  • 提问

  • 发视频

创作活动
3379

3379

  • 厂商:

    ADAFRUIT

  • 封装:

    -

  • 描述:

    FEATHER32U4BLUEFRUITLEWITHH

  • 数据手册
  • 价格&库存
3379 数据手册
Adafruit Feather 32u4 Bluefruit LE Created by lady ada https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le Last updated on 2022-12-01 02:19:34 PM EST ©Adafruit Industries Page 1 of 191 Table of Contents Overview Pinouts • • • • • • 16 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! Power Management • • • • • 12 Power Pins Logic pins Bluefruit LE Module + Indicator LEDs Other Pins! Top Side Bottom Side Assembly • • • • • • • • • 7 25 Battery + USB Power Power Supplies Measuring Battery ENable pin Alternative Power Options Arduino IDE Setup 29 Using with Arduino IDE 31 • • • • Install Drivers (Windows 7 Only) Blink Manually bootloading Ubuntu & Linux Issue Fix Installing BLE Library • • • • • • Install the Adafruit nRF51 BLE Library Run first example Uploading to the Feather Bluefruit LE Uploading to a brand new board/Upload failures Run the sketch AT command testing Configuration! • • • • • • 37 45 Which board do you have? Bluefruit Micro or Feather 32u4 Bluefruit Feather M0 Bluefruit LE Bluefruit LE SPI Friend Bluefruit LE UART Friend or Flora BLE Configure the Pins Used ©Adafruit Industries Page 2 of 191 • • • • • • • • • Common settings: Software UART Hardware UART Mode Pin SPI Pins Software SPI Pins Select the Serial Bus UART Based Boards (Bluefruit LE UART Friend & Flora BLE) SPI Based Boards (Bluefruit LE SPI Friend) BLEUart 51 • Opening the Sketch • Configuration • Running the Sketch HIDKeyboard • • • • • • • Opening the Sketch Configuration Running the Sketch Bonding the HID Keyboard Android iOS OS X Controller • • • • • • • 64 Opening the Sketch Configuration Running the Sketch Using Bluefruit LE Connect in Controller Mode Streaming Sensor Data Control Pad Module Color Picker Module HeartRateMonitor • • • • • • 56 71 Opening the Sketch Configuration If Using Hardware or Software UART Running the Sketch nRF Toolbox HRM Example CoreBluetooth HRM Example UriBeacon 76 • Opening the Sketch • Configuration • Running the Sketch HALP! 78 AT Commands 80 • • • • Test Command Mode '=?' Write Command Mode '=xxx' Execute Mode Read Command Mode '?' ©Adafruit Industries Page 3 of 191 Standard AT • • • • • AT ATI ATZ ATE +++ General Purpose • • • • • • 102 AT+BLEPOWERLEVEL AT+BLEGETADDRTYPE AT+BLEGETADDR AT+BLEGETPEERADDR AT+BLEGETRSSI BLE Services • • • • • • • • • • • 95 AT+BLEBEACON AT+BLEURIBEACON Deprecated: AT+EDDYSTONEENABLE AT+EDDYSTONEURL AT+EDDYSTONECONFIGEN AT+EDDYSTONESERVICEEN AT+EDDYSTONEBROADCAST BLE Generic • • • • • 89 AT+BAUDRATE AT+HWADC AT+HWGETDIETEMP AT+HWGPIO AT+HWGPIOMODE AT+HWI2CSCAN AT+HWVBAT AT+HWRANDOM AT+HWMODELED AT+UARTFLOW Beacon • • • • • • • 85 AT+FACTORYRESET AT+DFU AT+HELP AT+NVMWRITE AT+NVMREAD AT+MODESWITCHEN Hardware • • • • • • • • • • 82 105 AT+BLEUARTTX AT+BLEUARTTXF AT+BLEUARTRX AT+BLEUARTFIFO AT+BLEKEYBOARDEN AT+BLEKEYBOARD AT+BLEKEYBOARDCODE Modifier Values HID Keyboard Codes AT+BLEHIDEN AT+BLEHIDMOUSEMOVE ©Adafruit Industries Page 4 of 191 • • • • • • • • • 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 • • • • • • • 137 AT+DBGMEMRD AT+DBGNVMRD AT+DBGSTACKSIZE AT+DBGSTACKDUMP History • • • • • • • • • 129 GATT Limitations AT+GATTCLEAR AT+GATTADDSERVICE AT+GATTADDCHAR AT+GATTCHAR AT+GATTLIST AT+GATTCHARRAW Debug • • • • 122 Version Version Version Version Version Version Version Version Version 142 0.7.7 0.7.0 0.6.7 0.6.6 0.6.5 0.6.2 0.5.0 0.4.7 0.3.0 Command Examples 149 • Heart Rate Monitor Service • Python Script SDEP (SPI Data Transport) • • • • 152 SDEP Overview SPI Setup SPI Hardware Requirements IRQ Pin ©Adafruit Industries Page 5 of 191 • • • • • • • • • SDEP Packet and SPI Error Identifier Sample Transaction SDEP (Simple Data Exchange Protocol) Endianness Message Type Indicator SDEP Data Transactions Message Types Existing Commands SDEP AT Wrapper Usage GATT Service Details 163 • UART Service UART Service 163 • Characteristics • TX (0x0002) • RX (0x0003) Software Resources • • • • • • • • • • • 164 Bluefruit LE Client Apps and Libraries Bluefruit LE Connect (Android/Java) Bluefruit LE Connect  (iOS/Swift) Bluefruit LE Connect for OS X (Swift) Bluefruit LE Command Line Updater for OS X (Swift) Deprecated: Bluefruit Buddy (OS X) ABLE (Cross Platform/Node+Electron) Bluefruit LE Python Wrapper Debug Tools AdaLink (Python) Adafruit nRF51822 Flasher (Python) BLE FAQ 170 DFU Bluefruit Updates 181 Downloads 182 • Schematic • Fabrication Print Device Recovery 183 • How to Recover a Bluefruit Board • Still Having Problems? Feather HELP! ©Adafruit Industries 186 Page 6 of 191 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 32u4 Bluefruit - our take on an 'all-in-one' Arduinocompatible + Bluetooth Low Energy with built in USB and battery charging. Its an Adafruit Feather 32u4 with a BTLE module, ready to rock! We have other boards in the Feather family, check'em out here () Bluetooth Low Energy is the hottest new low-power, 2.4GHz spectrum wireless protocol. In particular, its the only wireless protocol that you can use with iOS without needing special certification and it's supported by all modern smart phones. This makes it excellent for use in portable projects that will make use of an iOS or Android phone or tablet. It also is supported in Mac OS X and Windows 8+ ©Adafruit Industries Page 7 of 191 At the Feather 32u4's heart is at ATmega32u4 clocked at 8 MHz and at 3.3V logic, a chip setup we've had tons of experience with as it's the same as the Flora (). This chip has 32K of flash and 2K of RAM, with built in USB so not only does it have a USB-toSerial program & debug capability built in with no need for an FTDI-like chip, it can also act like a mouse, keyboard, USB MIDI device, etc. To make it easy to use for portable projects, we added a connector for any of our 3.7V Lithium polymer batteries and built in battery charging. You don't need a battery, it will run just fine straight from the micro USB connector. But, if you do have a battery, you can take it on the go, then plug in the USB to recharge. The Feather will automatically ©Adafruit Industries Page 8 of 191 switch over to USB power when its available. We also tied the battery thru a divider to an analog pin, so you can measure and monitor the battery voltage to detect when you need a recharge. Here's some handy specs! Like all Feather 32u4'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 • ATmega32u4 @ 8MHz with 3.3V logic/power • 3.3V regulator with 500mA peak current output • USB native support, comes with USB bootloader and serial port debugging • You also get tons of pins - 20 GPIO pins • Hardware Serial, hardware I2C, hardware SPI support • 7 x PWM pins • 10 x analog inputs • Built in 100mA lipoly charger with charging status indicator LED • Pin #13 red LED for general purpose blinking • Power/enable pin • 4 mounting holes • Reset button The Feather 32u4 Bluefruit LE uses the extra space left over to add our excellent Bluefruit BTLE module + two status indicator LEDs ©Adafruit Industries Page 9 of 191 The Power of Bluefruit LE The Bluefruit LE module is an nRF51822 chipset from Nordic, programmed with multifunction 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 (). The board is capable of much more than just sending strings over the air!  Thanks to an easy to learn AT command set (), you have full control over how the device behaves, including the ability to define and manipulate your own GATT Services and Characteristics (), or change the way that the device advertises itself for other Bluetooth Low Energy devices to see. You can also use the AT commands  to query the die temperature, check the battery voltage, and more, check the connection RSSI or MAC address, and tons more. Really, way too long to list here! Use the Bluefruit App to get your project started Using our Bluefruit iOS App () or Android App (), you can quickly get your project prototyped by using your iOS or Android phone/tablet as a controller. We have a color  picker (), quaternion/accelerometer/gyro/magnetometer or location (GPS) (), and an 8button control game pad (). This data can be read over BLE and piped into the ATmega32u4 chip for processing & control ©Adafruit Industries Page 10 of 191 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. • Built in over-the-air bootloading capability so we can keep you updated with the hottest new firmware (). Use any Android or iOS device to get updates and install them. This will update the native code on the BLE module, to add new wireless capabilities, not program the ATmega chip. Comes fully assembled and tested, with a USB bootloader that lets you quickly use it with the Arduino IDE. We also toss in some header so you can solder it in and plug into a solderless breadboard. Lipoly battery, MicroSD card and USB cable not included (but we do have lots of options in the shop if you'd like!) ©Adafruit Industries Page 11 of 191 Pinouts Click here to view a PDF version of the pinout diagram () The Feather 32u4 Bluefruit LE is chock-full of microcontroller goodness. There's also a lot of pins and ports. We'll take you a tour of them now! The DFU pin is accidentally labeled GND on the bottom, sorry about that! it should be labeled DFU, dont use it as a GND ©Adafruit Industries Page 12 of 191 Power Pins • 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.3V • #0 / RX - GPIO #0, also receive (input) pin for Serial1 and Interrupt #2 • #1 / TX - GPIO #1, also transmit (output) pin for Serial1 and Interrupt #3 • #2 / SDA - GPIO #2, also the I2C (Wire) data pin. There's no pull up on this pin by default so when using with I2C, you may need a 2.2K-10K pullup. Also Interrupt #1 • #3 / SCL - GPIO #3, also the I2C (Wire) clock pin. There's no pull up on this pin by default so when using with I2C, you may need a 2.2K-10K pullup. Can also do PWM output and act as Interrupt #0. • #5 - GPIO #5, can also do PWM output • #6 - GPIO #6, can also do PWM output and analog input A7 • #9 - GPIO #9, also analog input A9 and can do PWM output. This analog input is connected to a voltage divider for the lipoly battery so be aware that this pin naturally 'sits' at around 2VDC due to the resistor divider • #10 - GPIO #10, also analog input A10 and can do PWM output. ©Adafruit Industries Page 13 of 191 • #11 - GPIO #11, can do PWM output. • #12 - GPIO #12, also analog input A11 • #13 - GPIO #13, can do PWM output and is connected to the red LED next to the USB jack • A0 thru A5 - These are each analog input as well as digital I/O pins. • SCK/MOSI/MISO - These are the hardware SPI pins, used by the Bluefruit LE module too! You can use them as everyday GPIO pins if you don't activate the Bluefruit and keep the BLE CS pin high. However, we really recommend keeping them free as they should be kept available for the Bluefruit. If they are used, make sure its with a device that will kindly share the SPI bus! Also used to reprogram the chip with an AVR programmer if you need. Bluefruit LE Module + Indicator LEDs Since not all pins can be brought out to breakouts, due to the small size of the Feather, we use these to control the BLE module • #8 - used as the Bluefruit CS (chip select) pin • #7 - used as the Bluefruit IRQ (interrupt request) pin. • #4 - used as the Bluefruit Reset pin Since these are not brought out there should be no risk of using them by accident! Other Pins! Top Side • RST - this is the Reset pin, tie to ground to manually reset the AVR, as well as launch the bootloader manually ©Adafruit Industries Page 14 of 191 • 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. You probably don't need to use this but its available if you need to upgrade!  Check out the DFU Bluefruit Upgrades page for how to use it. Otherwise, keep it disconnected. Bottom Side On the back we also have SWDIO/SWCLK/RESET pins, these are used for programming the Bluefruit LE module itself. SWD Debug Input You normally should not connect to the SWDIO and SWCLK pins unless you want to wipe out the Bluefruit LE module firmware for some reason, such as flashing an entirely custom firmware image written by yourself, though this is entirely at your own risk since it will wipe the Bluefruit firmware! Flashing firmware or using the SWD interface will require something like a Segger J-Link EDU Mini () to communicate via the debug controller inside the nRF51822. Factory Reset The Reset pad (not to be confused with the 0.1" circular RST pin!) is the factory reset pin, which is also rarely used, but  you can use it to set the module back to the factory default settings if it gets really messed up. Connect the 'Reset' pin to GND when you boot the device up to force a factory reset in HW (via the bootloader). ©Adafruit Industries Page 15 of 191 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 ©Adafruit Industries Page 16 of 191 Another option is to go with socket female headers. This won't let you plug the Feather into a breadboard but it will let you attach featherwings very easily ©Adafruit Industries Page 17 of 191 We also  have 'slim' versions of the female headers, that are a little shorter and give a more compact shape ©Adafruit Industries Page 18 of 191 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 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 ©Adafruit Industries Page 19 of 191 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 ()). ©Adafruit Industries Page 20 of 191 Solder the other strip as well. ©Adafruit Industries Page 21 of 191 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 ©Adafruit Industries Page 22 of 191 Flip & Tack Solder After flipping over, solder one or two points on each strip, to 'tack' the header in place ©Adafruit Industries Page 23 of 191 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 ()). ©Adafruit Industries Page 24 of 191 You're done! Check your solder joints visually and continue onto the next steps Power Management ©Adafruit Industries Page 25 of 191 Battery + USB Power We wanted to make our Feather boards easy to power both when connected to a computer as well as via battery. There's two ways to power a Feather: 1. You can connect with a USB cable (just plug into the jack) and the Feather will regulate the 5V USB down to 3.3V. 2. 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 rechargeable battery. When the USB power is powered, it will automatically switch over to USB for power, as well as start charging the battery (if attached). This happens 'hot-swap' style so you can always keep the LiPoly connected as a 'backup' power that will only get used when USB power is lost. The JST connector polarity is matched to Adafruit LiPoly batteries. Using wrong polarity batteries can destroy your Feather. 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 next to the USB jack, which will light up while the battery is charging. This LED might also flicker if the battery is not connected, it's normal. The charge LED is automatically driven by the LiPoly charger circuit. It will try to detect a battery and is expecting one to be attached. If there isn't one it may ©Adafruit Industries Page 26 of 191 flicker once in a while when you use power because it's trying to charge a (nonexistent) battery. It's not harmful, and its totally normal! Power Supplies You have a lot of power supply options here! We bring out the BAT pin, which is tied to the LiPoly JST connector, as well as USB which is the +5V from USB if connected. We also have the 3V pin which has the output from the 3.3V regulator. We use a 500mA peak regulator. While you can get 500mA from it, you can't do it continuously from 5V as it will overheat the regulator. It's fine for, say, powering an ESP8266 WiFi chip or XBee radio though, since the current draw is 'spiky' & sporadic. 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.7V. To make this easy we stuck a double-100K resistor divider on the BAT pin, and connected it to D9 (a.k.a analog #9 A9). You can read this pin's voltage, then double it, to get the battery voltage. #define VBATPIN A9 float measuredvbat = analogRead(VBATPIN); measuredvbat *= 2; // we divided by 2, so multiply back measuredvbat *= 3.3; // Multiply by 3.3V, our reference voltage ©Adafruit Industries Page 27 of 191 measuredvbat /= 1024; // convert to voltage Serial.print("VBat: " ); Serial.println(measuredvbat); This voltage will 'float' at 4.2V when no battery is plugged in, due to the lipoly charger output, so its not a good way to detect if a battery is plugged in or not (there is no simple way to detect if a battery is plugged in) 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. Alternative Power Options The two primary ways for powering a feather are a 3.7/4.2V LiPo battery plugged into the JST port or a USB power cable. ©Adafruit Industries Page 28 of 191 If you need other ways to power the Feather, here's what we recommend: • For permanent installations, a 5V 1A USB wall adapter () will let you plug in a USB cable for reliable power • For mobile use, where you don't want a LiPoly, use a USB battery pack! () • If you have a higher voltage power supply, use a 5V buck converter () and wire it to a USB cable's 5V and GND input () Here's what you cannot do: • Do not use alkaline or NiMH batteries and connect to the battery port - this will destroy the LiPoly charger and there's no way to disable the charger • Do not use 7.4V RC batteries on the battery port - this will destroy the board The Feather is not designed for external power supplies - this is a design decision to make the board compact and low cost. It is not recommended, but technically possible: • Connect an external 3.3V power supply to the 3V and GND pins. Not recommended, this may cause unexpected behavior and the EN pin will no longer work. Also this doesn't provide power on BAT or USB and some Feathers/Wings use those pins for high current usages. You may end up damaging your Feather. • Connect an external 5V power supply to the USB and GND pins. Not recommended, this may cause unexpected behavior when plugging in the USB port because you will be back-powering the USB port, which could confuse or damage your computer. 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 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. ©Adafruit Industries Page 29 of 191 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. To find the most up to date list of URLs you can add, you can visit the list of third party board URLs on the Arduino IDE wiki (). We will only need to add one URL to the IDE in this example, but you can add multiple URLS by separating them with commas. Copy and paste the link below into the Additional Boards Manager URLs option in the Arduino IDE preferences. ©Adafruit Industries Page 30 of 191 https://adafruit.github.io/arduino-board-index/ package_adafruit_index.json 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, ItsyBitsy 32u4, Trinket, & Trinket Pro. • Adafruit SAMD Boards - Includes support for Feather M0 and M4, Metro M0 and M4, ItsyBitsy M0 and M4, 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 (). If you have multiple boards you want to support, say ESP8266 and Adafruit, have both URLs in the text box separated by a comma (,) Once done click OK to save the new preference settings. Next we will look at installing boards with the Board Manager. Now continue to the next step to actually install the board support package! Using with Arduino IDE Since the Feather 32u4 uses an ATmega32u4 chip running at 8 MHz, you can pretty easily get it working with the Arduino IDE. Many libraries (including the popular ones like NeoPixels and display) work great with the '32u4 and 8 MHz clock speed. ©Adafruit Industries Page 31 of 191 Now that you have added the appropriate URLs to the Arduino IDE preferences, you can open the Boards Manager by navigating to the Tools->Board menu. Once the Board Manager opens, click on the category drop down menu on the top left hand side of the window and select Contributed. You will then be able to select and install the boards supplied by the URLs added to the prefrences. In the example below, we are installing support for Adafruit AVR Boards, but the same applies to all boards installed with the Board Manager. Next, 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. ©Adafruit Industries Page 32 of 191 Install Drivers (Windows 7 Only) When you plug in the Feather, you'll need to possibly install a driver Windows 10 folks can skip this, the drivers now come built into Windows 10! Click below to download our Driver Installer Download Adafruit Drivers Installer Download and run the installer Run the installer! Since we bundle the SiLabs and FTDI drivers as well, you'll need to click through the license ©Adafruit Industries Page 33 of 191 Select which drivers you want to install: Click Install to do the installin' ©Adafruit Industries Page 34 of 191 Blink Now you can upload your first blink sketch! Plug in the Feather 32u4 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 Feather 32u4! 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. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW ©Adafruit Industries Page 35 of 191 delay(1000); // wait for a second } And click upload! That's it, you will be able to see the LED blink rate change as you adapt the delay() calls. 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, double-click the RST button to get back into the bootloader. The red LED will pulse, so you know that its in bootloader mode. Do the reset button double-press right as the Arduino IDE says its attempting to upload the sketch, when you see the Yellow Arrow lit and the Uploading ... text in the status bar. 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 Ubuntu & Linux Issue Fix If you're on Linux, and are seeing multi-second delays connecting to the serial console, or are seeing "AT" and other gibberish when you connect, follow the steps on this page. () ©Adafruit Industries Page 36 of 191 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 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: ©Adafruit Industries Page 37 of 191 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 Page 38 of 191 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 if unused 4 // Optional but recommended, set to -1 (The Bluefruit Feather has the reset on digital #4 not #6) ©Adafruit Industries Page 39 of 191 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 ©Adafruit Industries Page 40 of 191 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. ©Adafruit Industries Page 41 of 191 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: ©Adafruit Industries Page 42 of 191 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 Page 43 of 191 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); ©Adafruit Industries Page 44 of 191 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. Your pinouts are Hardware SPI, CS = 8, IRQ = 7, RST = 4 Bluefruit Micro or Feather 32u4 Bluefruit If you have a Bluefruit Micro or Feather 32u4 Bluefruit LE then you have an ATmega32u4 chip with Hardware SPI, CS = 8, IRQ = 7, RST = 4 ©Adafruit Industries Page 45 of 191 Feather M0 Bluefruit LE If you have a Feather M0 Bluefruit LE then you have an ATSAMD21 chip with Hardware SPI, CS = 8, IRQ = 7, RST = 4 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 ©Adafruit Industries Page 46 of 191 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. There's also a MODE pin You can use this with just about any microcontroller with at least 3 pins, but best used with a Hardware Serial/UART capable chip! 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. ©Adafruit Industries Page 47 of 191 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. Debug output is 'noisy' on the serial console but is handy since you can see all communication between the micro and the BLE // ---------------------------------------------------------------------------------------------// 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. Some microcontrollers are limited on which pins can be used! Check the SoftwareSerial library documentation for more details // SOFTWARE UART SETTINGS #define BLUEFRUIT_SWUART_RXD_PIN #define BLUEFRUIT_SWUART_TXD_PIN #define BLUEFRUIT_UART_CTS_PIN #define BLUEFRUIT_UART_RTS_PIN 9 10 11 -1 // // // // Required for software serial! Required for software serial! Required for software serial! Optional, set to -1 if unused Hardware UART If you have Hardware Serial, there's a 'name' for it, usually Serial1 - you can set that up here: // HARDWARE UART SETTINGS #ifdef Serial1 // this makes it not complain on compilation if there's no Serial1 #define BLUEFRUIT_HWSERIAL_NAME Serial1 #endif Mode Pin For both hardware and software serial, you will likely want to define the MODE pin. There's a few sketches that dont use it, instead depending on commands to set/unset the mode. Its best to use the MODE pin if you have a GPIO to spare! ©Adafruit Industries Page 48 of 191 #define BLUEFRUIT_UART_MODE_PIN 12 // Set to -1 if unused SPI Pins 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 if unused 8 7 4 // Optional but recommended, set to -1 Software SPI Pins If you don't have a hardware SPI port available, you can use any three pins...its a tad slower but very flexible // SOFTWARE SPI SETTINGS #define BLUEFRUIT_SPI_SCK #define BLUEFRUIT_SPI_MISO #define BLUEFRUIT_SPI_MOSI 13 12 11 Refer to the table above to determine whether you have SPI or UART controlled Bluefruits! Select the Serial Bus Once you've configured your pin setup in the BluefruitConfig.h file, you can now check and adapt the example sketch. The Adafruit_BluefruitLE_nRF51 library supports four different serial bus options, depending on the HW you are using: SPI both hardware and software type, and UART both hardware and software type. UART Based Boards (Bluefruit LE UART Friend & Flora BLE) This is for Bluefruit LE UART Friend & Flora BLE boards. You can use either software serial or hardware serial. Hardware serial is higher quality, and less risky with respect ©Adafruit Industries Page 49 of 191 to losing data. However, you may not have hardware serial available! Software serial does work just fine with flow-control and we do have that available at the cost of a single GPIO pin. 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...uncomment these lines SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN); Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN, BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN); For boards that require hardware serial (Adafruit Flora, etc.), uncomment the hardware serial constructor, and make sure the other three options are commented out /* ...or hardware serial, which does not need the RTS/CTS pins. Uncomment this line */ Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, BLUEFRUIT_UART_MODE_PIN); SPI Based Boards (Bluefruit LE SPI Friend) For SPI based boards, you should uncomment the hardware SPI constructor below, making sure the other constructors are commented out: /* ...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); If for some reason you can't use HW SPI, you can switch to software mode to bit-bang the SPI transfers via the following constructor: /* ...software SPI, using SCK/MOSI/MISO user-defined SPI pins and then user selected CS/IRQ/RST */ Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_SCK, BLUEFRUIT_SPI_MISO, BLUEFRUIT_SPI_MOSI, BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST); ©Adafruit Industries Page 50 of 191 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 And roid () or iOS () in UART mode). Opening the Sketch To open the ATCommand sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select bleuart_cmdmode: This will open up a new instance of the example in the IDE, as shown below: ©Adafruit Industries Page 51 of 191 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 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) ©Adafruit Industries Page 52 of 191 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: Once you see the request, use the App to connect to the Bluefruit LE module in UART mode so you get the text box on your phone 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: ©Adafruit Industries Page 53 of 191 You can see the incoming string here in the Adafruit Bluefruit LE Connect app below (iOS in this case): ©Adafruit Industries Page 54 of 191 The response text ('Why hello, Arduino!') can be seen below: ©Adafruit Industries Page 55 of 191 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: ©Adafruit Industries Page 56 of 191 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 in CMD mode! ©Adafruit Industries Page 57 of 191 • 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 Page 58 of 191 To send keyboard data, type anything into the textbox at the top of the Serial Monitor and click the Send button. ©Adafruit Industries Page 59 of 191 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. When you no longer need a bond, or wish to bond the Bluefruit LE module to another device, be sure to delete the bonding information on the phone or PC, otherwise you may not be able to connect on a new device! Android To bond the keyboard on a Bluetooth Low Energy enabled Android device, go to the Settings application and click the Bluetooth icon. These screenshots are based on Android 5.0 running on a Nexus 7 2013. The exact appearance may vary depending on your device and OS version. Inside the Bluetooth setting panel you should see the Bluefruit LE module advertising itself as Bluefruit Keyboard under the 'Available devices' list: ©Adafruit Industries Page 60 of 191 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: To delete the bonding information, click the gear icon to the right of the device name and the click the Forget button: ©Adafruit Industries Page 61 of 191 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: 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 Page 62 of 191 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: To unbond the device once it has been paired, click the small 'x' icon beside Bluefruit Keyboard: ©Adafruit Industries Page 63 of 191 ... and then click the Remove button when the confirmation dialogue box pops up: Controller The Controller sketch allows you to turn your BLE-enabled iOS or Android device in a hand-held 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. Opening the Sketch To open the Controller sketch, click on the File > Examples > Adafruit_BluefruitLE_nRF51 folder in the Arduino IDE and select controller: ©Adafruit Industries Page 64 of 191 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 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. If ©Adafruit Industries Page 65 of 191 you do not set the MODE pin then make sure you have the mode switch in CMD mode • If you are using a Flora or otherwise don't want to wire up the Mode pin, set the 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 corner is set to 115200: Using Bluefruit LE Connect in Controller Mode Once the sketch is running you can open Adafruit's Bluefruit LE Connect application (available for Android () or iOS ()) and use the Controller application to interact with the sketch.  (If you're new to Bluefruit LE Connect, have a look at our dedicated Bluefruit LE Connect learning guide ().) ©Adafruit Industries Page 66 of 191 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). 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: ©Adafruit Industries Page 67 of 191 The data is parsed in the example sketch and output to the Serial Monitor as follows: Accel Accel Accel Accel Accel 0.20-0.51 0.22-0.50 0.25-0.51 0.21-0.47 0.27-0.48 ©Adafruit Industries -0.76 -0.83 -0.83 -0.76 -0.82 Page 68 of 191 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: 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 Page 69 of 191 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 ©Adafruit Industries Page 70 of 191 wearables! Download this combined sample code (configured for Feather but easy to adapt to FLORA, BLE Micro, etc.) to get started: feather_bluefruit_neopixel_animation_controller.zip 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 Page 71 of 191 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 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 Page 72 of 191 If you are using a Flora or just dont want to connect CTS or RTS, set the pin #define's to -1 and Don't forget to also connect the CTS pin on the Bluefruit to ground! (The Flora has this already done) If you are using RTS and CTS, you can remove this line below, which will slow down the data transmission // this line is particularly required for Flora, but is a good idea // anyways for the super long lines ahead! ble.setInterCharWriteDelay(5); // 5 ms 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 Page 73 of 191 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 Page 74 of 191 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 Page 75 of 191 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. You can edit the URL that the beacon will point to, from the default http://www.adafruit.com or just upload as is to test ©Adafruit Industries Page 76 of 191 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 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 Page 77 of 191 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:  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. ©Adafruit Industries Page 78 of 191 Solution? Once you are done debugging, remove these two lines from setup() while (!Serial); delay(500); I can't seem to "Find" the Bluefruit LE! Getting something like this? For UART/Serial Bluefruits: • Check you have the MODE switch in CMD and the MODE pin not wired to anything if it isnt used! • If you are trying to control the MODE from your micro, make sure you set the MODE 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 ©Adafruit Industries Page 79 of 191 If using SPI Bluefruit: • Make sure you have all 5 (or 6) wires connected properly. • If using hardware SPI, you need to make sure you're connected to the hardware SPI port, which differs depending on the main chipset. If using Bluefruit Micro: • Make sure you change the RESET pin to #4 in any Config file. Also be sure you are using hardware SPI to connect! 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.   Certain firmware versions or configurations may or may not include a specific command, and you can determine if the command is present by taking the command name and appending '=?' to it, as shown below AT+BLESTARTADV=? If the command is present, the device will reply with 'OK'.  If the command is not present, the device will reply with 'ERROR'. AT+BLESTARTADV=? OK\r\n AT+MISSINGCMD=? ERROR\r\n ©Adafruit Industries Page 80 of 191 Write Command Mode '=xxx' 'Write' mode is used to assign specific value(s) to the command, such as changing the radio's transmit power level using the command we used above. To write a value to the command, simple append an '=' sign to the command followed by any paramater(s) you wish to write (other than a lone '?' character which will be interpretted as tet mode): AT+BLEPOWERLEVEL=-8 If the write was successful, you will generally get an 'OK' response on a new line, as shown below: 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. Execute Mode 'Execute' mode will cause the specific command to 'run', if possible, and will be used when the command name is entered with no additional parameters. AT+FACTORYRESET You might use execute mode to perform a factory reset, for example, by executing the AT+FACTORYRESET command as follows: AT+FACTORYRESET OK\r\n ©Adafruit Industries Page 81 of 191 NOTE: Many commands that are means to be read will perform the same action whether they are sent to the command parser in 'execute' or 'read' mode. For example, the following commands will produce identical results: AT+BLEGETPOWERLEVEL -4\r\n OK\r\n AT+BLEGETPOWERLEVEL? -4\r\n OK\r\n 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.  Not every command supports read mode, but you generally use this to retrieve information like the current transmit power level for the radio by appending a '?' to the command, as shown below: AT+BLEPOWERLEVEL? If the command doesn't support read mode or if there was a problem with the request, you will normally get an 'ERROR' response. If the command read was successful, you will normally get the read results followed by 'OK' on a new line, as shown below: AT+BLEPOWERLEVEL? -4\r\n OK\r\n Note: For simple commands, 'Read' mode and 'Execute' mode behave identically. Standard AT The following standard Hayes/AT commands are available on Bluefruit LE modules: ©Adafruit Industries Page 82 of 191 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.0 Parameters: None Output: Displays the following values: • Board Name • Microcontroller/Radio SoC Name • Unique Serial Number • Core Bluefruit Codebase Revision • Project Firmware Revision • Firmware Build Date • Softdevice, Softdevice Version, Bootloader Version (0.5.0+) ATI BLEFRIEND nRF51822 QFAAG00 FB462DF92A2C8656 0.5.0 0.5.0 Feb 24 2015 S110 7.1.0, 0.0 OK ©Adafruit Industries Page 83 of 191 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.0 Parameters: None Output: None ATZ OK ATE Enables or disables echo of input characters with the AT parser Codebase Revision: 0.3.0 Parameters: '1' = enable echo, '0' = disable echo Output: None # Disable echo support ATE=0 OK #Enable echo support ATE=1 OK ©Adafruit Industries Page 84 of 191 +++ 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 will be displayed letting you know that you are back in COMMAND mode (see the two 'OK' entries in the sample code below). Codebase Revision: 0.4.7 Parameters: None Output: None Note that +++ can also be used on the mobile device to send and receive AT command on iOS or Android, though this should always be used with care. See the AT+MODESWITCHEN command to control the availability of the +++ command ATI BLEFRIEND nRF51822 QFAAG00 B122AAC33F3D2296 0.4.6 0.4.6 Dec 22 2014 OK +++ OK OK General Purpose The following general purpose commands are available on all Bluefruit LE modules: ©Adafruit Industries Page 85 of 191 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 Forces the module into DFU mode, allowing over the air firmware updates using a dedicated DFU app on iOS or Android. Codebase Revision: 0.3.0 Parameters: None Output: None The AT parser will no longer responsd after the AT+DFU command is entered, since normal program execution effectively halts and a full system reset is performed to start the bootloader code AT+DFU OK ©Adafruit Industries Page 86 of 191 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,AT+HWGETD OK AT+NVMWRITE Writes data to 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 • datatype: Which can be one of STRING (1), BYTEARRAY (2) or INTEGER (3) • data: The data to write to NVM memory (the exact payload format will change based on the specified datatype). Output: Nothing # Write 32768 as an integer starting at byte 16 in user NVM AT+NVMWRITE=16,INTEGER,32768 OK ©Adafruit Industries Page 87 of 191 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.  The value can be one of STRING (1), BYTEARRAY (2) or INTEGER (3) Output: The data read back, formatted based on the datatype argument. # Read an integer back from position 16 in user NVM AT+NVMREAD=16, 4, INTEGER 32768 OK AT+MODESWITCHEN Enables or disables mode switches via the '+++' command on the BLE peripheral of BLE UART side of the connection. Codebase Version: 0.7.1 Parameters: • location: This can be a string, either 'local' or 'ble' indicating which side should have the '+++' command enabled or disabled, 'local' being the Bluefruit peripheral and 'ble' being the phone or tablet. • state: '0' to disable '+++' mode switches, '1' to enable them. Output: None By default, '+++' is enabled locally, and disabled in BLE ©Adafruit Industries Page 88 of 191 # Disable reomte '+++' mode switches AT+MODESWITCHEN=ble,0 OK 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. Note that we do not recommend using higher baudrates than 9600 because the nRF51 UART can drop characters! Codebase Revision: 0.7.0 Parameters: Baud rate, which must be one of the following values: • 1200 • 2400 • 4800 • 9600 • 14400 • 19200 • 28800 • 38400 • 57600 • 76800 • 115200 • 230400 • 250000 • 460800 • 921600 • 1000000 Output: The current baud rate ©Adafruit Industries Page 89 of 191 # Set the baud rate to 115200 AT+BAUDRATE=115200 OK # Check the current baud rate AT+BAUDRATE 115200 OK 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 not be used as a replacement for a normal temperature sensor. Codebase Revision: 0.3.0 Parameters: None Output: The die temperature in degrees celcius AT+HWGETDIETEMP 32.25 OK ©Adafruit Industries Page 90 of 191 AT+HWGPIO Gets or sets the value of the specified GPIO pin (depending on the pin's mode). Codebase Revision: 0.3.0 Parameters: The parameters for this command change depending on the pin mode. OUTPUT MODE: The following comma-separated parameters can be used when updating a 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. Output: The pin state if you are reading an input or checking the state of an input pin (meaning only 1 parameter is supplied, the pin number), where: • 0 means the pin is logic low/GND • 1 means the pin is logic high/VCC Trying to set the value of a pin that has not been configured as an output will produce an 'ERROR' response. Some pins are reserved for specific functions on Bluefruit modules and can not be used as GPIO. If you try to make use of a reserved pin number an 'ERROR' response will be generated. # 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 ©Adafruit Industries Page 91 of 191 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.0 Parameters: This command one or two values (comma-separated in the case of two parameters being used): • The pin number • The new GPIO mode, where: ◦ 0 = Input ◦ 1 = Output ◦ 2 = Input with pullup enabled ◦ 3 = Input with pulldown enabled Output: If a single parameters is passed (the GPIO pin number) the current pin mode will be returned. Some pins are reserved for specific functions on Bluefruit modules and can not be used as GPIO. If you try to make use of a reserved pin number an 'ERROR' response will be generated. # Configure pin 14 as an output AT+HWGPIOMODE=14,0 OK # Get the current mode for pin 14 AT+HWPGIOMODE=14 0 OK ©Adafruit Industries Page 92 of 191 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. # I2C scan with two devices detected AT+HWI2CSCAN 0x23,0x35 OK # I2C scan with no devices detected AT+HWI2CSCAN OK AT+HWVBAT Returns the main power supply voltage level in millivolts Codebase Revision: 0.3.0 Parameters: None Output: The VBAT level in millivolts 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 ©Adafruit Industries Page 93 of 191 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.6 Parameters: LED operating mode, which can be one of the following values: • disable or DISABLE or 0 - Disable the MODE LED entirely to save power • mode or MODE or 1 - Default behaviour, indicates the current operating mode • hwuart or HWUART or 2 - Toggles the LED on any activity on the HW UART bus (TX or RX) • bleuart or BLEUART or 3 - Toggles the LED on any activity on the BLE UART Service (TX or RX characteristic) • spi or SPI or 4 - Toggles the LED on any SPI activity • manual or MANUAL or 5 - Manually sets the state of the MODE LED via a second comma-separated parameter, which can be on, off, or toggle. Output: If run with no parameters, returns an upper-case string representing the current 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 ©Adafruit Industries Page 94 of 191 AT+UARTFLOW Enables or disable hardware flow control (CTS + RTS) on the UART peripheral block of the nRF51822. Codebase Revision: 0.7.0 Parameters: HW flow control state, which can be one of: • on • off •0 •1 Output: If run with no parameters, returns a number representing whether flow control is enabled (1) or disabled (0). # Check the current flow control state AT+UARTFLOW 1 OK # Disable HW flow control AT+UARTFLOW=off OK 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.0 ©Adafruit Industries Page 95 of 191 Parameters: The following comma-separated parameters are required to enable beacon mode: • Bluetooth Manufacturer ID (uint16_t) • 128-bit UUID • Major Value (uint16_t) • Minor Value (uint16_t) • RSSI @ 1m (int8_t) Output: None # Enable Apple iBeacon emulation # Manufacturer ID = 0x004C AT+BLEBEACON=0x004C,01-12-23-34-45-56-67-78-89-9A-AB-BC-CD-DE-EFF0,0x0000,0x0000,-59 OK # Reset to change the advertising data ATZ OK # Enable Nordic Beacon emulation # Manufacturer ID = 0x0059 AT+BLEBEACON=0x0059,01-12-23-34-45-56-67-78-89-9A-AB-BC-CD-DE-EFF0,0x0000,0x0000,-59 OK # Reset to change the advertising data ATZ OK 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 Page 96 of 191 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 ©Adafruit Industries Page 97 of 191 • 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.). AT+BLEURIBEACON=http://www.adafruit.com/blog OK # Reset to change the advertising data ATZ OK 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. Deprecated: AT+EDDYSTONEENABLE This command will enable Eddystone () support on the Bluefruit LE module. Eddystone support must be enabled before the other related commands can be used. Codebase Revision: 0.6.6 Parameters: 1 or 0 (1 = enable, 0 = disable) Output: The current state of Eddystone support if no parameters are provided (1 = enabled, 0 = disabled) ©Adafruit Industries Page 98 of 191 This command was removed in firmware 0.7.0 to avoid confusion. Use AT+EDDYSTONESERVICEEN in 0.7.0 and higher. # 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 should be measured by the end user by checking the RSSI value on the receiving device at 1m and then adding 41 to that value (to compensate for the signal strength loss over 1m), so an RSSI of -62 at 1m would mean that you should enter -21 as the RSSI at 0m.  Default value is -18dBm. Output: Firmware = 0.6.7 running this command with no parameters will return the current URL. # Set the Eddystone URL to adafruit AT+EDDYSTONEURL=http://www.adafruit.com OK # Set the Eddystone URL to adafruit and advertise it even when connected AT+EDDYSTONEURL=http://www.adafruit.com,1 OK ©Adafruit Industries Page 99 of 191 AT+EDDYSTONECONFIGEN This command causes the Bluefruit LE module to enable the Eddystone URL config service for the specified number of seconds. 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.6 Parameters: The number of seconds to advertised the config service UUID Output: None # Start advertising the Eddystone config service for 5 minutes (300s) AT+EDDYSTONECONFIGEN=300 OK AT+EDDYSTONESERVICEEN Adds or removes the Eddystone service from the GATT table (requires a reset to take effect). Codebase Revision: 0.7.0 Parameters: Whether or not the Eddystone service should be enabled or not, using on of the following values: • on • off •1 •0 Output: If the command is executed with no parameters it will disable a numeric value indicating whether the service is enabled (1) or disabled (0). You must perform a system reset for this command to take effect. ©Adafruit Industries Page 100 of 191 # 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.0 Parameters: Whether or not the payload should be broadcast, using one of the following values: • on • off •1 •0 Output: If executed with no parameters, the current broadcast state will be displayed as a numeric value. # 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 Page 101 of 191 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.0 Parameters: The TX power level (in dBm), which can be one of the following values (from lowest to higher transmit power): • -40 • -20 • -16 • -12 • -8 • -4 •0 •4 Output: The current transmit power level (in dBm) The updated power level will take effect as soon as the command is entered. If the device isn't connected to another device, advertising will stop momentarily and then restart once the new power level has taken effect. # 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 ©Adafruit Industries Page 102 of 191 AT+BLEPOWERLEVEL=-3 ERROR AT+BLEGETADDRTYPE Gets the address type (for the 48-bit BLE device address). Normally this will be '1' (random), which means that the module uses a 48-bit address that was randomly generated during the manufacturing process and written to the die by the manufacturer. Random does not mean that the device address is randomly generated every time, only that a one-time random number is used. Codebase Revision: 0.3.0 Parameters: None Output: The address type, which can be one of the following values: • 0 = public • 1 = random AT+BLEGETADDRTYPE 1 OK 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 ©Adafruit Industries Page 103 of 191 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. Please note that the address returned by the central device is almost always a random value that will change over time, and this value should generally not be trusted. This command is provided for certain edge cases, but is not useful in most day to day scenarios. AT+BLEGETPEERADDR 48:B2:26:E6:C1:1D OK AT+BLEGETRSSI Gets the RSSI value (Received Signal Strength Indicator), which can be used to estimate the reliability of data transmission between two devices (the lower the number the better). 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 Page 104 of 191 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 () whi le 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). Output: This command will produce an ERROR message if you are not connected to a central device, or if the internal TX FIFO on the Bluefruit LE module is full. As of firmware release 0.6.2 and higher, AT+BLEUARTTX can accept a limited set of escape code sequences: • \r = carriage return • \n = new line • \t = tab • \b = backspace • \\ = backward slash As of firmware release 0.6.7 and higher, AT+BLEUARTTX can accept the following escape code sequence since AT+BLEUARTTX=? has a specific meaning to the AT parser: • \? = transmits a single question mark As of firmware release 0.7.6 and higher, AT+BLEUARTTX can accept the following escape code sequence: • \+ = transmit a single '+' character without having to worry about `+++` mode switch combinations ©Adafruit Industries Page 105 of 191 ESCAPE SEQUENCE NOTE: If you are trying to send escape sequences in code via something like 'ble.print("...");' please note that you will need to send a double 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.7, when the TX FIFO buffer is full a 200ms blocking delay will be used to see if any free space becomes available in the FIFO before returning ERROR. The exact process is detailed in the flow chart below: 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. ©Adafruit Industries Page 106 of 191 The TX FIFO has the following size, depending on the firmware version used: • Firmware =0.6.7: 1024 characters wide It IS possible with large data transfers that part of the payload can be transmitted, and the command can still produce an ERROR if the FIFO doesn't empty in time in the middle of the payload transfer (since data is transmitted in maximum 20 byte chunks). If you need to ensure reliable data transfer, you should always check the 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). This command will accept a maximum of 20 characters, which is the limit of what can be send in a single packet. Codebase Revision: 0.7.6 Parameters: See AT+BLEUARTTX Output: See AT+BLEUARTTX AT+BLEUARTRX This command will dump the UART service ()'s RX buffer to the display if any data has been received from from the UART service while running in Command Mode. The data will be removed from the buffer once it is displayed using this command. Any characters left in the buffer when switching back to Data Mode will cause the buffered characters to be displayed as soon as the mode switch is complete (within the limits of available buffer space, which is 1024 bytes on current black 32KB SRAM ©Adafruit Industries Page 107 of 191 devices, or 160 bytes for the blue first generation BLEFriend board based on 16KB SRAM parts). Codebase Revision: 0.3.0 Parameters: None Output: The RX buffer's content if any data is available, otherwise nothing. You can also use the AT+BLEUARTFIFO=RX command to check if any incoming data is available or not. # 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.7 Parameters: Running this command with no parameters will return two commaseparated values indicating the free space in the TX buffer, following by the RX buffer.  To request a specific buffer, you can execute the command with either a "TX" or "RX" value (For example: "AT+BLEUARTFIFO=TX"). Output: The free space remaining in the TX and RX FIFO buffer if no parameter is present, otherwise the free space remaining in the specified FIFO buffer. AT+BLEUARTFIFO 1024,1024 OK AT+BLEUARTFIFO=TX 1024 OK ©Adafruit Industries Page 108 of 191 AT+BLEUARTFIFO=RX 1024 OK AT+BLEKEYBOARDEN This command will enable GATT over HID (GoH) keyboard support, which allows you to 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.6 this command is now an alias for AT+BLEHIDEN You must perform a system reset (ATZ) before the changes take effect! Before you can use your HID over GATT keyboard, you will need to bond your mobile device with the Bluefruit LE module in the Bluetooth preferences panel. # Enable BLE keyboard support then reset AT+BLEKEYBOARDEN=1 OK ATZ OK # Disable BLE keyboard support then reset AT+BLEKEYBOARDEN=0 OK ATZ OK AT+BLEKEYBOARD Sends text data over the BLE keyboard interface (if it has previously been enabled via AT+BLEKEYBOARDEN). ©Adafruit Industries Page 109 of 191 Any valid alpha-numeric character can be sent, and the following escape sequences are also supported: • \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 (special use case, 0.6.7+) AT+BLEKEYBOARD=\? OK AT+BLEKEYBOARDCODE Sends a raw hex sequence of USB HID keycodes to the BLE keyboard interface including key modifiers and up to six alpha-numeric characters. This command accepts the following string-encoded byte array payload, matching the way HID over GATT sends keyboard data: • Byte 0: Modifier • Byte 1: Reserved (should always be 00) • Bytes 2..7: Hexadecimal value(s) corresponding to the HID keys (if no character is used you can enter '00' or leave trailing characters empty) ©Adafruit Industries Page 110 of 191 After a keycode sequence is sent with the AT+BLEKEYBOARDCODE command, you must send a second AT+BLEKEYBOARDCODE command with at least two 00 characters to 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 ('-').  Note that these are HID scan code values, not standard ASCII values! Output: None HID Keyboard Codes A list of hexademical-format HID keyboard codes can be found here () (see section 7), and are listed below for convenience sake: HID key code values don't correspond to ASCII key codes! For example, 'a' has an HID keycode value of '04', and there is no keycode for an upper case 'A' since you use the modifier to set upper case values. For details, google 'usb hid keyboard scan codes', and see the example below. 0x00Reserved 0x01Keyboard 0x02Keyboard 0x03Keyboard 0x04Keyboard 0x05Keyboard 0x06Keyboard 0x07Keyboard (no event indicated) ErrorRollOver POSTFail ErrorUndefined a and A b and B c and C d and D ©Adafruit Industries Page 111 of 191 0x08Keyboard e and E 0x09Keyboard f and F 0x0AKeyboard g and G 0x0BKeyboard h and H 0x0CKeyboard i and I 0x0DKeyboard j and J 0x0EKeyboard k and K 0x0FKeyboard l and L 0x10Keyboard m and M 0x11Keyboard n and N 0x12Keyboard o and O 0x13Keyboard p and P 0x14Keyboard q and Q 0x15Keyboard r and R 0x16Keyboard s and S 0x17Keyboard t and T 0x18Keyboard u and U 0x19Keyboard v and V 0x1AKeyboard w and W 0x1BKeyboard x and X 0x1CKeyboard y and Y 0x1DKeyboard z and Z 0x1EKeyboard 1 and ! 0x1FKeyboard 2 and @ 0x20Keyboard 3 and # 0x21Keyboard 4 and $ 0x22Keyboard 5 and % 0x23Keyboard 6 and ^ 0x24Keyboard 7 and & 0x25Keyboard 8 and * 0x26Keyboard 9 and ( 0x27Keyboard 0 and ) 0x28Keyboard Return (ENTER) 0x29Keyboard ESCAPE 0x2AKeyboard DELETE (Backspace) 0x2BKeyboard Tab 0x2CKeyboard Spacebar 0x2DKeyboard - and (underscore) 0x2EKeyboard = and + 0x2FKeyboard [ and { 0x30Keyboard ] and } 0x31Keyboard \ and | 0x32Keyboard Non-US # and ~ 0x33Keyboard ; and : 0x34Keyboard ' and " 0x35Keyboard Grave Accent and Tilde 0x36Keyboard, and < 0x37Keyboard . and > 0x38Keyboard / and ? 0x39Keyboard Caps Lock 0x3AKeyboard F1 0x3BKeyboard F2 0x3CKeyboard F3 0x3DKeyboard F4 0x3EKeyboard F5 0x3FKeyboard F6 0x40Keyboard F7 0x41Keyboard F8 0x42Keyboard F9 0x43Keyboard F10 0x44Keyboard F11 0x45Keyboard F12 0x46Keyboard PrintScreen 0x47Keyboard Scroll Lock 0x48Keyboard Pause 0x49Keyboard Insert 0x4AKeyboard Home 0x4BKeyboard PageUp 0x4CKeyboard Delete Forward ©Adafruit Industries Page 112 of 191 0x4DKeyboard End 0x4EKeyboard PageDown 0x4FKeyboard RightArrow 0x50Keyboard LeftArrow 0x51Keyboard DownArrow 0x52Keyboard UpArrow 0x53Keypad Num Lock and Clear 0x54Keypad / 0x55Keypad * 0x56Keypad 0x57Keypad + 0x58Keypad ENTER 0x59Keypad 1 and End 0x5AKeypad 2 and Down Arrow 0x5BKeypad 3 and PageDn 0x5CKeypad 4 and Left Arrow 0x5DKeypad 5 0x5EKeypad 6 and Right Arrow 0x5FKeypad 7 and Home 0x60Keypad 8 and Up Arrow 0x61Keypad 9 and PageUp 0x62Keypad 0 and Insert 0x63Keypad . and Delete 0x64Keyboard Non-US \ and | 0x65Keyboard Application 0x66Keyboard Power 0x67Keypad = 0x68Keyboard F13 0x69Keyboard F14 0x6AKeyboard F15 0x6BKeyboard F16 0x6CKeyboard F17 0x6DKeyboard F18 0x6EKeyboard F19 0x6FKeyboard F20 0x70Keyboard F21 0x71Keyboard F22 0x72Keyboard F23 0x73Keyboard F24 0x74Keyboard Execute 0x75Keyboard Help 0x76Keyboard Menu 0x77Keyboard Select 0x78Keyboard Stop 0x79Keyboard Again 0x7AKeyboard Undo 0x7BKeyboard Cut 0x7CKeyboard Copy 0x7DKeyboard Paste 0x7EKeyboard Find 0x7FKeyboard Mute 0x80Keyboard Volume Up 0x81Keyboard Volume Down 0x82Keyboard Locking Caps Lock 0x83Keyboard Locking Num Lock 0x84Keyboard Locking Scroll Lock 0x85Keypad Comma 0x86Keypad Equal Sign 0x87Keyboard International1 0x88Keyboard International2 0x89Keyboard International3 0x8AKeyboard International4 0x8BKeyboard International5 0x8CKeyboard International6 0x8DKeyboard International7 0x8EKeyboard International8 0x8FKeyboard International9 0x90Keyboard LANG1 0x91Keyboard LANG2 ©Adafruit Industries Page 113 of 191 0x92Keyboard 0x93Keyboard 0x94Keyboard 0x95Keyboard 0x96Keyboard 0x97Keyboard 0x98Keyboard 0x99Keyboard 0x9AKeyboard 0x9BKeyboard 0x9CKeyboard 0x9DKeyboard 0x9EKeyboard 0x9FKeyboard 0xA0Keyboard 0xA1Keyboard 0xA2Keyboard 0xA3Keyboard 0xA4Keyboard 0xE0Keyboard 0xE1Keyboard 0xE2Keyboard 0xE3Keyboard 0xE4Keyboard 0xE5Keyboard 0xE6Keyboard 0xE7Keyboard LANG3 LANG4 LANG5 LANG6 LANG7 LANG8 LANG9 Alternate Erase SysReq/Attention Cancel Clear Prior Return Separator Out Oper Clear/Again CrSel/Props ExSel LeftControl LeftShift LeftAlt Left GUI RightControl RightShift RightAlt Right GUI The following example shows how you can use this command: # send 'abc' with left shift key (0x02) --> 'ABC' AT+BLEKEYBOARDCODE=02-00-04-05-06-00-00 OK # Indicate that the keys were released (mandatory!) AT+BLEKEYBOARDCODE=00-00 OK AT+BLEHIDEN This command will enable GATT over HID (GoH) support, which allows you to emulate a 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.6 Parameters: 1 or 0 (1 = enable, 0 = disable) Output: None ©Adafruit Industries Page 114 of 191 You normally need to 'bond' the Bluefruit LE peripheral to use the HID commands, and the exact bonding process will change from one operating system to another. If you have previously bonded to a device and need to clear the bond, you can run the AT+FACTORYRESET command which will erase all stored bond data on the Bluefruit LE module. # Enable GATT over HID support on the Bluefruit LE module AT+BLEHIDEN=1 OK # Reset so that the changes take effect ATZ OK AT+BLEHIDMOUSEMOVE Moves the HID mouse or scroll wheen position the specified number of ticks. All parameters are signed 8-bit values (-128 to +127).  Positive values move to the right or down, and origin is the top left corner. Codebase Revision: 0.6.6 Parameters: X Ticks (+/-), Y Ticks (+/-), Scroll Wheel (+/-), Pan Wheel (+/-) Output: None # 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). ©Adafruit Industries Page 115 of 191 Codebase Revision: 0.6.6 Parameters: Button Mask String [L][R][M][B][F], Action [PRESS][CLICK][DOUBLECLICK] [HOLD] • L = Left Button • R = Right Button • M = Middle Button • B = Back Button • F = Forward Button • If the second parameter (Action) is "HOLD", an optional third parameter can be passed specifying how long the button should be held in milliseconds. Output: None # 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 selection, etc.). Codebase Revision: 0.6.6 Parameters: The HID control key to send, followed by an optional delay in ms to hold the button ©Adafruit Industries Page 116 of 191 The control key string can be one of the following values: • System Controls (works on most systems) ◦ BRIGHTNESS+ ◦ BRIGHTNESS• Media Controls (works on most systems) ◦ PLAYPAUSE ◦ MEDIANEXT ◦ MEDIAPREVIOUS ◦ MEDIASTOP • Sound Controls (works on most systems) ◦ VOLUME ◦ MUTE ◦ BASS ◦ TREBLE ◦ BASS_BOOST ◦ VOLUME+ ◦ VOLUME◦ BASS+ ◦ BASS◦ TREBLE+ ◦ TREBLE• Application 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). ©Adafruit Industries Page 117 of 191 Output: Normally none. If you are not bonded and connected to a central device, this command will return ERROR. Make sure you are connected and HID support is enabled before running these commands. # 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.6 Parameters: Whether the gamepad service should be enabled via one of the following values: • on • off •1 •0 Output: If executed with no parameters, a numeric value will be returned indicating whether the battery service is enabled (1) or disabled (0). This command requires a system reset to take effect. AT+BLEHIDGAMEPAD Sends a specific HID gamepad payload out over BLE ©Adafruit Industries Page 118 of 191 Codebase Revision: 0.7.0 Parameters: The following comma-separated parameters are available: • 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: You need to send both 'press' and 'release' events for each button, otherwise the system will think that the button is still pressed until a release state is received. # Press 'RIGHT' and 'Button0' at the same time AT+BLEHIDGAMEPAD=1,0,0x01 # Press 'UP' and 'Button1' + 'Button0' at the same time AT+BLEHIDGAMEPAD=0,-1,0x03 AT+BLEMIDIEN Enables or disables the BLE MIDI service. Codebase Revision: 0.7.0 Parameters: State, which can be one of: • on • off •0 •1 Output: If executed with no parameters, it will return the current state of the MIDI service as an integer indicating if it is enabled (1) or disabled (0). ©Adafruit Industries Page 119 of 191 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.0 Parameters: The MIDI event in hex array format, which can be either: • A series of full MIDI events (up to 4 events) • Exactly 1 full MIDI event + several running events without status (up to 7) Output: None # 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 ©Adafruit Industries Page 120 of 191 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.0 Parameters: Whether the battery service should be enabled, via on of the following values: • on • off •1 •0 Output: If executed with no parameters, a numeric value will be returned indicating whether the battery service is enabled (1) or disabled (0). This command requires a system reset to take effect. # Enable the Battery Service AT+BLEBATTEN=1 OK AT+BLEBATTVAL Sets the current battery level in percentage (0..100) for the Battery Service (if enabled). Codebase Revision: 0.7.0 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. ©Adafruit Industries Page 121 of 191 # Set the battery level to 72% AT+BLEBATTVAL=72 OK 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. AT+GAPCONNECTABLE This command can be used to prevent the device from being 'connectable'. Codebase Revision: 0.7.0 Parameters: Whether or not the device should advertise itself as connectable, using one of the following values: • yes • no •1 •0 Output: The 'connectable' state of the device if no parameter is provided # Make the device non-connectable (advertising only) AT+GAPCONNECTABLE=0 OK # Check the current connectability status AT+GAPCONNECTABLE 1 OK ©Adafruit Industries Page 122 of 191 AT+GAPGETCONN Diplays the current connection status (if we are connected to another BLE device or not). 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.0 ©Adafruit Industries Page 123 of 191 Parameters: • None to read the current device name • The new device name if you want to change the value 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. # Read the current device name AT+GAPDEVNAME UART OK # Update the device name to 'BLEFriend' AT+GAPDEVNAME=BLEFriend OK # Reset to take effect ATZ OK AT+GAPDELBONDS Deletes and bonding information stored on the Bluefruit LE module. Codebase Revision: 0.3.0 Parameters: None Output: None AT+GAPDELBONDS OK AT+GAPINTERVALS Gets or sets the various advertising and connection intervals for the Bluefruit LE module. ©Adafruit Industries Page 124 of 191 Be extremely careful with this command since it can be easy to cause problems changing the intervals, and depending on the values selected some mobile devices may no longer recognize the module or refuse to connect to it. 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. The default value is 30 seconds ('Fast Advertising Timeout'). The low power advertising interval is hard-coded to approximately 0.6s in firmware < 0.7.0. Support to control the low power interval was added in the 0.7.0 firmware release via an optional fifth parameter. Please note the following min and max limitations for the GAP parameters: • Absolute minimum connection interval: 10ms • Absolute maximum connection interval: 4000ms • Absolute minimum fast advertising interval: 20ms • Absolute maximum fast advertisting interval: 10240ms • Absolute minimum low power advertising interval: 20ms • Absolute maximum low power advertising interval: 10240ms If you only wish to update one interval value, leave the other comma-separated values empty (ex. ',,110,' will only update the third value, advertising interval). Output: If reading the current GAP interval settings, the following comma-separated information will be displayed: • Minimum connection interval (in milliseconds) • Maximum connection interval (in milliseconds) • Advertising interval (in milliseconds) ©Adafruit Industries Page 125 of 191 • Advertising timeout (in milliseconds) 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. # Read the current GAP intervals AT+GAPINTERVALS 20,100,100,30 # Update all values AT+GAPINTERVALS=20,200,200,30 OK # Update only the advertising interval AT+GAPINTERVALS=,,150, OK AT+GAPSTARTADV Causes the Bluefruit LE module to start transmitting advertising packets if this isn't already the case (assuming we aren't already connected to an external device). Codebase Revision: 0.3.0 Parameters: None Output: None # Command results when advertising data is not being sent AT+GAPSTARTADV OK # Command results when we are already advertising AT+GAPSTARTADV ERROR # Command results when we are connected to another device AT+GAPSTARTADV ERROR AT+GAPSTOPADV Stops advertising packets from being transmitted by the Bluefruit LE module. ©Adafruit Industries Page 126 of 191 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.3) and the various Service UUID lists (Part A, Section 1.1). A list of all possible GAP Data Types is available on the Bluetooth SIG's Generic Access Profile () page. The Advertising Data payload consists of Generic Access Profile () data that is inserted into the advertising packet in the following format: [U8:LEN] [U8:Data Type Value] [n:Value] WARNING: This command requires a degree of knowledge about the low level details of the Bluetooth 4.0 or 4.1 Core Specification, and should only be used by expert users. Misuse of this command can easily cause your device to be undetectable by central devices in radio range. WARNING: This command will override the normal advertising payload and may prevent some services from acting as expected. To restore the advertising data to the normal default values use the AT+FACTORYRESET command. 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: ©Adafruit Industries Page 127 of 191 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. anyone can discover this device) ◦ BR/EDR Not Supported (i.e. this is a Bluetooth Low Energy only device) If we also want to include two 16-bit service UUIDs in the advertising data (so that listening devices know that we support these services) we could append the following data to the byte array: 05-02-0D-18-0A-18 • 0x05 indicates that the number of bytes in the entry (5) • 0x02 is the 'Data Type Value ()' and indicates that this is an 'Incomplete List of 16-bit Service Class UUIDs' • 0x0D 0x18 is the first 16-bit UUID (which translates to 0x180D, corresponding to the Heart Rate Service ()). • 0x0A 0x18 is another 16-bit UUID (which translates to 0x180A, corresponding to the Device Information Service ()). Including the service UUIDs is important since some mobile applications will only work with devices that advertise a specific service UUID in the advertising packet. This is true for most apps from Nordic Semiconductors, for example. Codebase Revision: 0.3.0 Parameters: The raw byte array that should be inserted into the advertising data section of 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 ©Adafruit Industries Page 128 of 191 The results of this command can be seen in the screenshot below, taken from a sniffer analyzing the advertising packets in Wireshark. The advertising data payload is higlighted in blue in the raw byte array at the bottom of the image, and the packet analysis is in the upper section: 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. Please note that any characteristics that you define here will automatically be saved to non-volatile FLASH config memory on the device and re-initialised the next time the device starts. You need to perform a system reset via 'ATZ' before most of the commands below will take effect! ©Adafruit Industries Page 129 of 191 GATT Limitations The commands below have the following limitations due to SRAM and resource availability, which should be kept in mind when creating or working with customer GATT services and characteristics. These values apply to firmware 0.7.0 and higher: • Maximum number of services: 10 • Maximum number of characteristics: 30 • Maximum buffer size for each characteristic: 32 bytes • Maximum number of CCCDs: 16 If you want to clear any previous config value, enter the 'AT+FACTORYRESET' command before working on a new peripheral configuration. AT+GATTCLEAR Clears any custom GATT services and characteristics that have been defined on the device. Codebase Revision: 0.3.0 Parameters: None Response: None AT+GATTCLEAR OK AT+GATTADDSERVICE Adds a new custom service definition to the device. Codebase Revision: 0.3.0 ©Adafruit Industries Page 130 of 191 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.  128-bit values should be in the following format: 00-11-22-33-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF  Response: The index value of the service in the custom GATT service lookup table. (It's important to keep track of these index values to work with the service later.) Note: Key values are not case-sensitive Only one UUID type can be entered for the service (either UUID or UUID128) # 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 characteristic to the above service (making sure that there # is no conflict between the 16-bit UUID and bytes 3+4 of the 128-bit service UUID) AT+GATTADDCHAR=UUID=0x0002,PROPERTIES=0x02,MIN_LEN=1,VALUE=100 1 OK AT+GATTADDCHAR Adds a custom characteristic to the last service that was added to the peripheral (via AT+GATTADDSERVICE). ©Adafruit Industries Page 131 of 191 AT+GATTADDCHAR must be run AFTER AT+GATTADDSERVICE, and will add the new characteristic to the last service definition that was added. As of version 0.6.6 of the Bluefruit LE firmware you can now use custom 128-bit UUIDs with this command. See the example at the bottom of this command 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'). This value must be unique, and should not conflict with bytes 3+4 of the parent service's 128-bit UUID. • PROPERTIES: The 8-bit characteristic properties field, as defined by the Bluetooth SIG. The following values can be used: ◦ 0x02 - Read ◦ 0x04 - Write Without Response ◦ 0x08 - Write ◦ 0x10 - Notify ◦ 0x20 - Indicate • MIN_LEN: The minimum size of the values for this characteristic (in bytes, min = 1, max = 20, default = 1) • MAX_LEN: The maximum size of the values for the characteristic (in bytes, min = 1, max = 20, default = 1) • VALUE: The initial value to assign to this characteristic (within the limits of 'MIN_LEN' and 'MAX_LEN'). Value can be an integer ("-100", "27"), a hexadecimal value ("0xABCD"), a byte array ("aa-bb-cc-dd") or a string ("GATT!"). • >=0.7.0 - DATATYPE: This argument indicates the data type stored in the characteristic, and is used to help parse data properly.  It can be one of the following values: ◦ AUTO (0, default) ◦ STRING (1) ◦ BYTEARRAY (2) ◦ INTEGER (3) ©Adafruit Industries Page 132 of 191 • >=0.7.0 - DESCRIPTION: Adds the specified string as the characteristic description entry • >=0.7.0 - PRESENTATION: Adds the specified value as the characteristic presentation format entry 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.) Note: Key values are not case-sensitive Make sure that the 16-bit UUID is unique and does not conflict with bytes 3+4 of the 128-bit service UUID # 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 characteristic to the above service (making sure that there # is no conflict between the 16-bit UUID and bytes 3+4 of the 128-bit service UUID) AT+GATTADDCHAR=UUID=0x0002,PROPERTIES=0x02,MIN_LEN=1,VALUE=100 1 OK 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: ©Adafruit Industries Page 133 of 191 # 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-EEFF,PROPERTIES=0x02,MIN_LEN=1,VALUE=100 1 OK Version 0.7.0 of the Bluefruit LE firmware added the new DESCRIPTION and PRESENT ATION keywoards, corresponding the the GATT Characteristic User Description () and the GATT Characteristic Presentation Format () Descriptors. The DESCRIPTION field is a string that contains a short text description of the characteristic.  Some apps may not display this data, but it should be visible using something like the Master Control Panel application from Nordic on iOS and Android. The PRESENTATION field contains a 7-byte payload that encapsulates the characteristic presentation format data.  It requires a specific set of bytes and values to work properly. See the following link for details on how to format the payload: https ://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx? u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml () The following example shows how you might use both of these new fields: AT+GATTADDCHAR=UUID=0x2A37, PROPERTIES=0x10, MIN_LEN=2, MAX_LEN=3, VALUE=00-40, DESCRIPTION=HRM Measurement, PRESENTATION=17-00-AC-27-01-00-00 For the Characteristic Presentation Format we have: • Format = IEEE-11073 32-bit FLOAT (Decimal 23, Hex 0x17) • Exponent = 0/None • Unit = Thermodynamic temperature: Degrees Fahrenheit (0x27AC) - Bluetooth LE Unit List () • Namespace = Bluetooth SIG Assigned Number (0x01) • Description = None (0x0000) The results from Nordic's Master Control Panel app can be seen below: ©Adafruit Industries Page 134 of 191 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). • The first parameter is the characteristic index value, as returned from the AT+GATTADDCHAR function. This parameter is always required, and if no second parameter is entered the current value of this characteristic will be returned. • The second (optional) parameter is the new value to assign to this characteristic (within the MIN_SIZE and MAX_SIZE limits defined when creating it). Response: If the command is used in read mode (only the characteristic index is provided as a value), the response will display the current value of the characteristics.  If the command is used in write mode (two comma-separated values are provided), the characteristics will be updated to use the provided value. # 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 ©Adafruit Industries Page 135 of 191 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+GATTCHAR=1 0x20 OK AT+GATTLIST Lists all custom GATT services and characteristics that have been defined on the device. Codebase Revision: 0.3.0 Parameters: None Response: A list of all custom services and characteristics defined on the device. # 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 conflict between the 16-bit UUID and bytes 3+4 of the 128-bit service UUID) AT+GATTADDCHAR=UUID=0x0002,PROPERTIES=0x02,MIN_LEN=1,VALUE=100 2 OK # Get a list of all custom GATT services and characteristics on the device AT+GATTLIST ID=01,UUID=0x180F ID=01,UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,MAX_LEN=1,VALUE=0x64 ID=02,UUID=0x11, UUID128=00-11-00-11-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF ©Adafruit Industries Page 136 of 191 ID=02,UUID=0x02,PROPERTIES=0x02,MIN_LEN=1,MAX_LEN=1,VALUE=0x64 OK AT+GATTCHARRAW This read only command reads binary (instead of ASCII) data from a characteristic. It is non-printable but has less overhead and is easier when writing libraries in Arduino. Codebase Revision: 0.7.0 Parameters: The numeric ID of the characteristic to display the data for Output: Binary data corresponding to the specified characteristic. Note: This is a specialized command and no NEWLINE is present at the end of the command! 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.0 Parameters: The following comma-separated parameters can be used with this command: • The starting address to read memory from (in hexadecimal form, with or without the leading '0x') • The word size (can be 1, 2, 4 or 8) • The number of words to read ©Adafruit Industries Page 137 of 191 Output: The raw memory contents in hexadecimal format using the specified length and word size (see examples below for details) # Read 12 1-byte values starting at 0x10000009 AT+DBGMEMRD=0x10000009,1,12 FF FF FF FF FF FF FF 00 04 00 00 00 OK # Try to read 2 4-byte values starting at 0x10000000 AT+DBGMEMRD=0x10000000,4,2 55AA55AA 55AA55AA OK # Try to read 2 4-byte values starting at 0x10000009 # This will fail because the Cortex M0 can't perform misaligned # reads, and any non 8-bit values must start on an even address AT+DBGMEMRD=0x10000009,4,2 MISALIGNED ACCESS ERROR 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 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ©Adafruit Industries 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Page 138 of 191 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 OK 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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.7 Parameters: None Output: The current size of stack memory in bytes AT+DBGSTACKSIZE 1032 OK AT+DBGSTACKDUMP Dumps the current stack contents. Unused sections of stack memory are filled with '0xCAFEFOOD' to help determine where stack usage stops. This command is purely for debug and development purposes. Codebase Revision: 0.4.7 ©Adafruit Industries Page 139 of 191 Parameters: None 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 0x20003950: CAFEF00D 0x20003960: CAFEF00D 0x20003970: CAFEF00D 0x20003980: CAFEF00D 0x20003990: CAFEF00D 0x200039A0: CAFEF00D 0x200039B0: CAFEF00D 0x200039C0: CAFEF00D 0x200039D0: CAFEF00D 0x200039E0: CAFEF00D 0x200039F0: CAFEF00D 0x20003A00: CAFEF00D 0x20003A10: CAFEF00D 0x20003A20: CAFEF00D 0x20003A30: CAFEF00D 0x20003A40: CAFEF00D 0x20003A50: CAFEF00D 0x20003A60: CAFEF00D 0x20003A70: CAFEF00D 0x20003A80: CAFEF00D 0x20003A90: CAFEF00D 0x20003AA0: CAFEF00D 0x20003AB0: CAFEF00D 0x20003AC0: CAFEF00D 0x20003AD0: CAFEF00D 0x20003AE0: CAFEF00D 0x20003AF0: CAFEF00D 0x20003B00: CAFEF00D 0x20003B10: CAFEF00D 0x20003B20: CAFEF00D 0x20003B30: CAFEF00D 0x20003B40: CAFEF00D 0x20003B50: CAFEF00D 0x20003B60: CAFEF00D 0x20003B70: CAFEF00D 0x20003B80: CAFEF00D 0x20003B90: CAFEF00D 0x20003BA0: CAFEF00D 0x20003BB0: CAFEF00D 0x20003BC0: CAFEF00D ©Adafruit Industries CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D CAFEF00D Page 140 of 191 0x20003BD0: 0x20003BE0: 0x20003BF0: 0x20003C00: 0x20003C10: 0x20003C20: 0x20003C30: 0x20003C40: 0x20003C50: 0x20003C60: 0x20003C70: 0x20003C80: 0x20003C90: 0x20003CA0: 0x20003CB0: 0x20003CC0: 0x20003CD0: 0x20003CE0: 0x20003CF0: 0x20003D00: 0x20003D10: 0x20003D20: 0x20003D30: 0x20003D40: 0x20003D50: 0x20003D60: 0x20003D70: 0x20003D80: 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 CAFEF00D CAFEF00D CAFEF00D 00000004 CAFEF00D CAFEF00D 00000001 20001BB0 00000006 20001C6C 20001D38 00000001 00550000 000080E8 60140000 80000000 00000000 200018D4 0000011C 00000000 0000011C 0000011C 00000048 0001E326 000080E8 61C78000 0000A1FC 00000000 000080E8 622C8000 40011000 00000000 62780000 00000000 20003DF8 00000200 00000001 00000001 2000311B 20002050 20002050 20002050 20002050 00000001 00000000 00021263 20003ED8 20003ED4 00000008 FFFFFFFF 20302058 20002050 32002050 20002050 00000000 20003F40 200030D4 000001D8 6C383025 1FFF4000 200020C7 FFFFFFFF 200020B4 200020B0 CAFEF00D FFFFFFFF 00000000 ©Adafruit Industries CAFEF00D CAFEF00D CAFEF00D 20001D04 00001098 CAFEF00D 200018D8 000134A5 00000006 20001D44 00000005 00012083 00000001 00000009 20002764 000080E8 0001E4D9 00000000 0001BCE1 0001BC1D 0001BDA9 FFFFFFF9 00000010 00000001 0001E9CF 000080E8 0002125C 0012A236 00000009 0012A29B 000185EF 00000004 00018579 20003054 0002085D 0001F663 2000311B 00000000 00000042 200030D4 20003F1B 0001FFA3 0001FF8B 0012A54E 20002050 00000005 20002050 20003054 20003F64 00000008 2000311B 00000000 32303032 200030D4 20002050 200030D4 20003F60 00016559 00000058 00000028 000166C5 200020B8 000180AD 200020B0 CAFEF00D FFFFFFFF 00000000 CAFEF00D CAFEF00D 00000000 CAFEF00D CAFEF00D 00001006 20001C50 0000100D 20001C38 00000006 20001D38 200018C8 80E80000 60900000 0009608F 00000000 80E80000 80E80000 0000203A 80E80000 80E80000 008B8000 0000A000 80E80000 00000000 00000048 00000000 00000000 00004998 00000042 00006E10 0000000C 2000311B 20002050 00000001 00000001 0001F631 0000000C 200030D4 20002050 20002050 00000005 00000010 00000020 200030D4 0000000C 200030D4 00000000 00000084 00000001 0001F631 0000000C 00323330 20002050 00000020 00000004 000001D6 0000000C 200030D4 00000028 000166AD 2000306C 1FFF4000 1FFF4000 200020B4 1FFF4000 00000000 CAFEF00D CAFEF00D CAFEF00D FFFFEF68 CAFEF00D 200018D8 00000004 20001D28 20001D44 00000005 00000000 000013D3 4FC40000 000080E8 000080E8 00129F5F 200018C8 000000FF 0001BC1D 0001BCE1 0001BDA9 0001BC1D 00000009 51538000 00000009 00000504 000080E8 0001E4D9 000080E8 0001E479 00000000 00000000 0001ACDF 00000001 200030D4 200030D4 00020A6D 200030D4 00020AD7 00020833 0001FF89 20003ED8 00020491 00022409 0001FF8B 20003F74 00020187 20003F75 FFFFFFFF 00000008 00020A6D 200030D4 000258D7 00020833 000001CE 0001ED83 000001D7 00000000 FFFFFFFF 000217F8 00017ED9 200030D4 200020B0 0001A63D 00000002 00000000 00016113 Page 141 of 191 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. • Adjusted BLE UART service to use min connection interval as the tx interval • Added AT+DFUIRQ to enable using the DFU Pin for IRQ purposes when there is a supported event on the nRF51822 • Enabled the internal pullup resistor on the CS pin for Bluefruit SPI boards • Added AT+MODESWITCHEN to enable/disable +++ mode switching from the local (serial or SPI) or BLE UART side. By default local = enabled, ble = disabled, meaning commands can only be executed via the local interface by default. • Implemented a '\+' escape code to immediately send '+' chars without trigger the +++ delay waiting for further similar input • Added AT+BLEHIDGAMEPADEN to separately enable HID Gamepad, since iOS/ OSX has a conflict with gamepad devices causing HID keyboard to not work properly. The following bugs were fixed in release 0.7.7: • Fixed a factory reset issue when a long delay occurs in app_error_handler() • Fixed an issue where strings were being truncated at 64 chars in UART • Fixed HID keyboard support not working with iOS 9 & 10 Version 0.7.0 The following AT commands were added in the 0.7.0 release: • AT+BAUDRATE Change the HW UART baudrate ©Adafruit Industries Page 142 of 191 • AT+UARTFLOW Enable or disable HW UART flow control • AT+BLEMIDIEN=on/off/0/1 Enable/disable MIDI service, requires a reset to take effect • AT+BLEMIDITX 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. Datatype must be STRING (1), BYTEARRAY (2), or INTEGER (3) • AT+NVMREAD=offset,size,datatype Reads data back from 256 bytes user NVM • AT+NVMREADRAW=offset,size binary data Binary data (instead of ASCII) is returned, ending with "OK\r\n". It is non-printable but less overhead and easier to use in some situations. • AT+BLEHIDGAMEPAD=x,y,buttons ◦ X is LEFT, RIGHT: X=-1 LEFT is pressed, X=1 RIGHT is pressed, X=0 no pressed ◦ Y is UP, DOWN: Y=-1 i UP, Y=1 is DOWN, Y=0 no pressed ◦ Button [0x00-0xFF] is a bit mask for 8 button 0-7 • AT+GAPCONNECTABLE=on/off/1/0 Allow/disallow connection to the device • AT+EDDYSTONESERVICEEN Add/remove EddyStone service to GATT table (requires reset) • AT+EDDYSTONEBROADCAST=on/off/0/1 Start/stop broadcasting url using settings from NVM • AT+BLEBATTEN=on/off/1/0 Enable battery service. Reset required due to the service change. • AT+BLEBATTVAL=percent Updates the Battery level, percent is 0 to 100 ©Adafruit Industries Page 143 of 191 The following commands were changed in the 0.7.0 release: • AT+GATTADDCHAR ◦ Added a DATATYPE option to indicate the data type for the GATT characteristic's payload. Valid option are: AUTO (0, default), STRING (1), BYTEARRAY (2), INTEGER (3) ◦ Added characteristic user description option via the DESCRIPTION flag ◦ Added characteristic presentation format support via the PRESENTATION flag • AT+GAPINTERVALS Added a new 'adv_lowpower_interval' parameter, default value is 417.5 ms. Current arguments are now:  min_conn, max_conn, adv_interval, adv_timeout, adv_lowpower_interval Key bug fixes and changes in this release: • Significant BTLE UART speed and reliability improvements • Added callback support (work in progress) for: ◦ BLE UART RX ◦ GATT Characteristic(s) RX ◦ MIDI RX ◦ Connect/Disconnect • Increased MAX_LEN for each characteristic from 20 to 32 bytes • Changed the default GAP parameters: ◦ Advertising interval = 20ms ◦ Min connection interval = 20 ms ◦ Max connection interval = 40 ms • Increased the maximum number of CCCDs saved to flash from 8 to 16 • Eddystone config service disabled by default • Removed AT+EDDYSTONEENABLE to avoid confusion • Changed advertising timeout for Eddystone to 'unlimited' • Fixed Write-No-Response characteristic property, which wasn't being handled properly • Fixed timing constraints to meet Apple design guidelines • Fixed systick to ms calculation • Fixed all tests with google eddystone validator except for writing tx_power = 1 dB (not valid on nrf51) ©Adafruit Industries Page 144 of 191 • Fixed a bug where writing from the central does not update the value on the characteristic correctly • Fixed an issue with HID examples, where when paired with Central, a disconnect then reconnect could not send HID reports anymore Version 0.6.7 The following AT commands were added in the 0.6.7 release: • AT+BLEUARTFIFO Returns the number of free bytes available in the TX and RX FIFOs for the Bluetooth UART Service. 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+BLEKEYBOARD=?' has another meaning for the AT parser. To send a single question mark the following command should be used: 'AT+BLEKEYBOARD=\?' or 'AT+BLEUARTTX=\?' • AT+EDDYSTONEURL This command now accepts an optional third parameter for RSSI at 0m value (default is -18dBm).  Running this command with no parameters ('AT+EDDYSTONEURL\r\n') will now return the current URL. Key bug fixes in this release: • The FIFO handling for the Bluetooth UART Service was improved for speed and stability, and the TX and RF FIFOs were increased to 1024 bytes each. ©Adafruit Industries Page 145 of 191 • An issue where a timer overflow was causing factory resets every 4 hours or so has been resolved. • Fixed a problem with the GATT server where 'value_len' was being incorrectly parsed for integer values in characteristics where 'max_len' >4 Version 0.6.6 The following AT commands were added in the 0.6.6 release: • AT+EDDYSTONEURL Update the URL for the beacon and switch to beacon mode • AT+EDDYSTONEENABLE Enable/disable beacon mode using the configured url • AT+EDDYSTONECONFIGEN Enable advertising for the the Eddystone configuration service for the specified number of seconds • 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.) • AT+BLEHIDEN Enables or disables BLE HID support in the Bluefruit LE firmware (mouse, keyboard and media control) • AT+BLEMOUSEMOVE To move the HID mouse • AT+BLEMOUSEBUTTON To set the state of the HID mouse buttons The following commands were changed in the 0.6.6 release: • AT+BLEKEYBOARDEN - Now an alias for AT+BLEHIDEN • AT+GATTADDCHAR - Added a new UUID128 field to allow custom UUIDs Key bug fixes in this release: • Fixed issues with long beacon URLs • Fixed big endian issue in at+blebeacon for major & minor number ©Adafruit Industries Page 146 of 191 Known issues with this release: • Windows 10 seems to support a limited number of characteristics for the DIS service. We had to disable the Serial Number characteristic to enable HID support with windows 10. Version 0.6.5 The following AT commands were added in the 0.6.5 release: • AT+BLEGETPEERADDR () The following commands were changed in the 0.6.5 release: • Increased the UART buffer size (on the nRF51) from 128 to 256 bytes • +++ now responds with the current operating mode • Fixed a bug with AT+GATTCHAR values sometimes not being saved to NVM • 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.2 release: • AT+BLEUARTTX () Basic escape codes were added for new lines, tabs and backspace • AT+BLEKEYBOARD () Also works with OS X now, and may function with other operating systems that support BLE HID keyboards ©Adafruit Industries Page 147 of 191 Version 0.5.0 The following AT commands were added in the 0.5.0 release: • AT+BLEKEYBOARDEN () • AT+BLEKEYBOARD () • AT+BLEKEYBOARDCODE () The following AT commands were changed in the 0.5.0 release: • ATI () The SoftDevice, SoftDevice version and bootloader version were added as a new (7th) record. For Ex: "S110 7.1.0, 0.0" indicates version 7.1.0 of the S110 softdevice is used with the 0.0 bootloader (future boards will use a newer 0.1 bootloader). Other notes concerning 0.5.0: Starting with version 0.5.0, you can execute the AT+FACTORYRESET command at any point (and without a terminal emulator) by holding the DFU button down for 10 seconds until the blue CONNECTED LED starts flashing, then releasing it. Version 0.4.7 The following AT commands were added in the 0.4.7 release: • +++ () • 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 ©Adafruit Industries Page 148 of 191 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 Command Examples The following code snippets can be used when operating in Command Mode to perform specific tasks. Heart Rate Monitor Service The command list below will add a Heart Rate () service to the BLEFriend's attribute table, with two characteristics: • Heart Rate Measurement () • Body Sensor Location () # Perform a factory reset to make sure we get a clean start AT+FACTORYRESET OK # Add the Heart Rate service entry AT+GATTADDSERVICE=UUID=0x180D 1 OK # Add the Heart Rate Measurement characteristic AT+GATTADDCHAR=UUID=0x2A37, PROPERTIES=0x10, MIN_LEN=2, MAX_LEN=3, VALUE=00-40 1 OK # Add the Body Sensor Location characteristic AT+GATTADDCHAR=UUID=0x2A38, PROPERTIES=0x02, MIN_LEN=1, VALUE=3 2 OK # Create a custom advertising packet that includes the Heart Rate service UUID AT+GAPSETADVDATA=02-01-06-05-02-0d-18-0a-18 OK # Reset the device to start advertising with the custom payload ATZ OK # Update the value of the heart rate measurement (set it to 0x004A) ©Adafruit Industries Page 149 of 191 AT+GATTCHAR=1,00-4A OK 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 + " <serialPort>\n" print "For example:\n" print " Windows : " + filename + " COM14" print " OS X : " + filename + " /dev/tty.usbserial-DN009WNO" print " Linux : " + filename + " /dev/ttyACM0" return def checkargs(): """Validates the command-line arguments for this script""" if len(sys.argv) < 2: print "ERROR: Missing serialPort" usage() sys.exit(-1) if len(sys.argv) > 2: print "ERROR: Too many arguments (expected 1)." usage() sys.exit(-2) def errorhandler(err, exitonerror=True): """Display an error message and exit gracefully on "ERROR\r\n" responses""" print "ERROR: " + err.message if exitonerror: ser.close() sys.exit(-3) 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.rstrip() + ©Adafruit Industries Page 150 of 191 "'") if __name__ == '__main__': # Make sure we received a single argument (comPort) checkargs() # This will automatically open the serial port (no need for ser.open) ser = serial.Serial(port=sys.argv[1], baudrate=9600, rtscts=True) serio = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1), newline='\r\n', line_buffering=True) # Add the HRM service and characteristic definitions try: atcommand("AT+FACTORYRESET", 1000) # Wait 1s for this to complete atcommand("AT+GATTCLEAR") atcommand("AT+GATTADDSERVICE=UUID=0x180D") atcommand("AT+GATTADDCHAR=UUID=0x2A37, PROPERTIES=0x10, MIN_LEN=2, MAX_LEN=3, VALUE=00-40") atcommand("AT+GATTADDCHAR=UUID=0x2A38, PROPERTIES=0x02, MIN_LEN=1, VALUE=3") atcommand("AT+GAPSETADVDATA=02-01-06-05-02-0d-18-0a-18") # Perform a system reset and wait 1s to come back online atcommand("ATZ", 1000) # Update the value every second while True: atcommand("AT+GATTCHAR=1,00-%02X" % random.randint(50, 100), 1000) except ValueError as err: # One of the commands above returned "ERROR\n" errorhandler(err) except KeyboardInterrupt: # Close gracefully on CTRL+C ser.close() sys.exit() 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 Page 151 of 191 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). ©Adafruit Industries Page 152 of 191 Most of the time, you never need to deal with SDEP directly, but we've documented the protocol here in case you need understand the Bluefruit LE SPI interface in depth! SDEP Overview SDEP was designed as a bus neutral protocol to handle binary commands and responses -- including error responses -- in a standard, easy to extend manner. 'Bus neutral' means that we can use SDEP regardless of the transport mechanism (USB HID, SPI, I2C, Wireless data over the air, etc.). All SDEP messages have a four byte header, and in the case of the Bluefruit LE modules up to a 16 byte payloads. Larger messages are broken up into several 4+16 bytes message chunks which are rebuilt at either end of the transport bus. The 20 byte limit (4 byte header + 16 byte payload) was chosen to take into account the maximum packet size in Bluetooth Low Energy 4.0 (20 bytes per packet). SPI Setup While SDEP is bus neutral, in the case of the Bluefruit LE SPI Friend or Shield, an SPI transport is used with the following constraints and assumptions, largely to take into account the HW limitations of the nRF51822 system on chip: SPI Hardware Requirements • The SPI clock should run

很抱歉,暂时无法提供与“3379”相匹配的价格&库存,您可以联系我们找货

免费人工找货