Bluefruit LE Connect For iOS and Android: Created by Collin Cunningham
Bluefruit LE Connect For iOS and Android: Created by Collin Cunningham
The Bluefruit LE Connect app provides iOS & Android devices with a variety of tools to communicate with Bluefruit LE
devices. These tools cover basic communication and info reporting as well as more project specific uses such as
Arduino Pin Control and a Color Picker.
The iOS app is a free download from Apple's App Store (https://adafru.it/ddu). It requires iOS 11.3 or later and works on
iPhones, iPads, and iPod Touches.
The Android app is a free download from the Google Play Store (https://adafru.it/f4G). It requires Android 4.4 or later.
The app is compatible with these BLE devices from Adafruit, and possibly more:
First off - install the app from one of the App stores listed above if you haven't already.
Enable Bluetooth
If Bluetooth is disabled on your device, enable it by going to Settings->Bluetooth on your iOS device, or the analogous
setting on your Android device.
Don't forget to turn on Bluetooth on your device! Airplane Mode turns off BLE.
iPhone
The following images depict the app when used on the iPhone. The Android app looks similar.
The device list will display all BLE devices discovered by the app (not just Bluefruit hardware) - so you may see a quite
a few "" entries for devices that don't advertise their name, as seen above.
To refresh the list and start a new scan, simply swipe down on the current list.
Each device's signal strength is displayed in the left side of its row.
If you tap on the device entry (not on Connect), you'll see more detail about a particular device:
Any device listed with a "Connect" button at the right can be accessed in Info mode.
Any device listed as "UART Capable" can be used with all modes - Info, UART, Pin I/O, & Controller.
To use the Bluefruit Connect app with your device it must be "UART capable"! All Adafruit BLE devices
implement the UART interface, but other devices may not
Connect
Tap the Connect button on the UART capable list entry you wish to use and choose a connection mode from the menu
that appears.
If you’re having trouble finding your Bluefruit device in the scanned peripherals list, ensure the board is powered and
not paired with any other BLE devices. If the problem persists, it could be due to caching issues in the iOS or Android
operating system. For a fix, try the following:
Cycle Bluetooth - Turn your mobile device’s Bluetooth radio off and on again in the Settings app.
Relaunch App - Quit the Bluetooth LE Connect app and restart it. (instructions for iOS (https://adafru.it/DMn) &
Android (https://adafru.it/DMo))
Cycle Power - Restart your mobile device by powering it off and restarting.
Doing one or both of the above solves most peripheral scanning issues. If you're still having trouble, try searching the
Adafruit Support forum (https://adafru.it/DMl) for your issue.
Each of these modes can do different things and let you interact in a unique way.
Don't forget! All of these modes use the UART Service, but present the data in a different way. On the hardware side,
your firmware will have to know what it is expecting and sometimes may need to parse the data coming back from the
app.
For example, if using the Color Picker, the app will send the color data in a mini packet. If using the button controller,
you'll get button presses/releases in packets instead.
Available Modes:
Info (https://adafru.it/BYg)
UART Terminal Mode (https://adafru.it/xSF)
MQTT (https://adafru.it/yb7)
Plotter (https://adafru.it/xTa)
Controller (https://adafru.it/iCI) (Data Streaming (https://adafru.it/DN9), Control Pad (https://adafru.it/DN9), and
Color Picker (https://adafru.it/DN9))
AHRS/Calibration (https://adafru.it/Gge)
This mode is available for all connectable BLE devices and can be helpful for learning, troubleshooting, and
general curious snooping.
Tapping on a service row will reveal that service's included characteristics.
To learn more about Bluetooth Services & Characteristics, be sure to check out the Introduction to Bluetooth Low
Energy guide (https://adafru.it/iCp).
It's perfect for sending and receiving data without any interpretation.
Note: This mode can be used in conjunction with Bluefruit LE Friend's Command mode (https://adafru.it/iCO) to
configure or get additional info about the device.
Main Window
The main log window is in the middle, and will display data both received and, if Echo is on, sent.
Echo
Toggle the Echo switch in the settings the upper right to also display outgoing data sent from the app.
ASCII will do its best to translate the data to 8-bit human-viewable text characters.
Hex will give you 0xnn formatted bytes, still color coded.
Sending Strings
MQTT stands for Message Queue Telemetry Transport. It's a protocol designed for low-bandwidth, high latency
networks. You can learn more about it here. (https://adafru.it/yqD)
The Bluefruit LE Connect App allows you to send and receive data using the MQTT protocol. For example - this can be
useful for making sensor readings from a Bluefruit device viewable on the web.
To access the MQTT settings, simply click the MQTT button in the top right corner of the UART Terminal.
Configuration
Firstly, you will need an adafruit.io (https://adafru.it/fJs) account in order to log and collect your data. You can make one
here (https://adafru.it/eZ8). To learn more about adafruit.io, check out the guide for it here (https://adafru.it/yqE).
Keep in mind that adafruit.io has a rate limit of 1Hz, so your project shouldn't send data faster than once per second.
Once you have your adafruit.io account set up, connect to your device using the Bluefruit LE Connect app and open the
UART mode. In the UART module, tap the "MQTT X" button at the top of the screen.
Under SERVER, enter "io.adafruit.com" as the server address and "1883" as the port.
You can name them anything you like, but in this example will name the feed used to display data received by the
board as "rx"), and another used to display data entered through the app as "tx". We'll also have a third feed named
"output" which will display new data on the Bluefruit LE Connect app, called "output".
Finally, under ADVANCED, use your adafruit.io username. Under Password, use your adafruit.io account's KEY. This can
be found under the settings of your adafruit.io account.
Example
Here are some examples of feeds created using the Bluefruit LE Connect app in the same manor as described above.
Received Data
Written Data
This is an example of a TX feed that presents data sent from the Bluefruit LE Connect app to adafruit.io via MQTT.
Output Data
This is an example of an output feed that presents data created on adafruit.io sent to the Bluefruit LE Connect app via
MQTT
Feel free to test the plotting feature using this demo sketch (https://adafru.it/xTc)!
If you're running into issues sending data to the Plotter, try limiting throughput to 10 values per second.
This is what the Bluefruit LE Connect app displays by default if there is no data to plot.
Formatting
The app interprets incoming numeric values in ASCII format. Separate data values should be followed by a comma or
tab character. Separate each set of values sent using a newline character or simply use ble.println() (which
automatically appends a newline char). This allows Bluefruit LE Connect to know when to plot the next set of values.
For example, a properly formatted stream of plotter values will look like this when viewed in the app's
UART terminal (https://adafru.it/xTd):
A plot utilizing 3 data streams would look something like the picture shown below:
When switched on, AutoScroll will adjust the graph size and follow the most recent data collected by the Bluefruit LE
Connect app
When turned off, swipe left and right to scroll through your data. Use the Width slider to adjust the width of the graph.
Each Controller data packet sent is prefixed with single byte char “!” (0x21) followed by a single byte char initial
for identification.
Sensor data values are encoded as floats of 4 byte length.
Each packet ends with a single byte checksum for validation.
Checksum
The single-byte checksum that appends each Controller data packet is calculated by adding all previous bytes of the
packet and then inverting the sum.
An example of how to use the checksum to validate a Controller packet can be found in the
BLE_Controller_Test (https://adafru.it/exz) Arduino sketch:
Serial.print("CRC ");
else {
Serial.println("FAIL");
return false;
}
Sensors
The top section of the Controller table lists the available types of sensor data which can be streamed from your iOS
device. Tap the button at the right of each sensor row to begin streaming its relevant data.
All sensor data updates, except for Location, are sent out over BLE ten times per second.
Location updates are sent whenever GPS data changes, or every 30 seconds if no change occurs.
• Quaternion - sends iOS Device Motion data to describe device attitude. This data is derived from Accelerometer,
Gyro, and Magnetometer readings.
Prefix: !Q
Format:
Prefix: !A
Format:
Prefix: !G
Prefix: !M
Format:
• Location - sends GPS data, requires user permission before initial use.
Prefix: !L
Format:
Control Pad
Prefix: !B
Examples:
Color Picker
The Color Picker sends a color's RGB values to Bluefruit LE. This can be used to control the state of RGB LEDs such as
Neopixels (https://adafru.it/exA).
• Press Send to send the chosen color's red, green, and blue values to Bluefruit via UART in the following format:
Prefix: !C
Format:
Note: Any activated sensor data streams will continue while using the Color Picker.
The AHRS/Calibrarion feature allows you to generate and test calibration code for Magnetometer and Gyroscope
sensors connected to your NRF51 based Bluefruit LE device.
Process
Download and run this sketch on your NRF51 powered Bluefruit board:
https://adafru.it/A7T
https://adafru.it/A7T
Connect to your Bluefruit board using the calibration app and choose either Magnetometer or Gyroscope mode
depending on what sensor you'll be calibrating.
Keep rotating slowly in a sphere until you get decent coefficients (this can be a bit tricky and takes some trial and error
to get right).
Once you have data, note it down as shown in the USB example above.
https://adafru.it/A7U
https://adafru.it/A7U
Testing
Connect to your Bluefruit board and run the '3D Visualisation' mode on the app. You will see a 3D model of a
bunny. Readings sent from your Bluefruit board should allow you to rotate the model by rotating your board.
Updating Firmware
You’ll first be presented with a list of compatible firmware versions. Choose the one you want to use (you'll usually want
the newest one at the top of the list).
Custom Firmware
You can also update your device with an your own unlisted firmware by tapping the Use Custom Firmware button.
You’ll be asked to locate the relevant file (iOS users can access files via iCloud) and then update process will begin as
above.
The Image Transfer mode allows you to select an image and transmit it over BLE. The interface also offers a number of
additional features for advanced users.
Data Format
Image data is sent from over BLE in the following format:
Choose Image
Bit Depth
This setting toggles between two color bit-depth settings: 16-bit & 24-bit. This value determines how many bits of data
are used to represent each pixel’s color value. A higher value allows for a greater range of colors, but uses more data
and time to transfer.
Resolution
Transfer Mode
Without Response (fastest, least reliable): App never waits for response before sending more data
With Response (slowest, most reliable): App always waits for response to before sending more data
Interleaved (customizable, varies): App sends a number of packets w/o response before sending one w response.
The default value of 50 offers a nice middle ground between speed and reliability.
Example code written for Circuit Playground Bluefruit + TFT Gizmo is only compatible with default Transfer
Mode of Interleaved [50:1]
The image can be rotated using the buttons on either side of the Send Image button.
• Each row in the table represents a pin on your Arduino. Pin name and current state are displayed on the left side of
the cell, while pin value is displayed on the right.
• Tap a row to change the relevant pin's current mode and value.
You can use the nrf8001-based or nrf51822-based breakouts. However, the setup will vary slightly.
Install Libraries
You'll want to start by installing the BLE Firmata library (https://adafru.it/fTO). Use the Library manager to find Adafruit
BLEFirmata and install it
At the top of the sketch is the Firmata configuration section, there's also Bluefruit LE pin configuration in the
BluefruitConfig.h tab
You'll need to change your pins if you are using UART or different SPI pins.
Check out the generic "Configuration!" details for information on what every pin does. If you're using software serial, be
sure to set up flow control and a MODE pin. (https://adafru.it/kCT)
Then in the main sketch, if you're not using hardware SPI, uncomment the connection style you want
/* ...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);
/* ...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);
/* ...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);
// Change this to whatever is the Serial console you want, either Serial or SerialUSB
#define FIRMATADEBUG Serial
// Pause for Serial console before beginning?
#define WAITFORSERIAL true
// Print all BLE interactions?
#define VERBOSE_MODE false
The first setting FIRMATADEBUG is how output is printed. 99% of the time you'll be happy with Serial, but for Arduino
Zeros you may need to use SerialUSB for the native port.
WAITFORSERIAL determines whether the sketch waits for the Serial port to be opened before it runs. Set it to true
while debugging/testing and open up the serial console to kick off the sketch. Set to false once it's working great
VERBOSE_MODE allows you to see all of the data passing between the BLE module and App.
You'll need to uncomment one of these lines. Also, they are set up by default for the SPI Bluefruit module, on pins 4, 7,
8. For that reason, the hardware SPI pins and 4,7,8 don't appear. If you are using different pins you can re-add those to
For the 32u4 and M0 examples, there's a lot of pins, & perhaps not all of them are necessary! You can have as few as
you like.
Below the setup lines you can see the way we tell Firmata which pins do what
#if defined(__AVR_ATmega328P__)
// Standard setup for UNO, no need to tweak
uint8_t boards_analogiopins[] = {A0, A1, A2, A3, A4, A5}; // A0 == digital 14, etc
uint8_t boards_pwmpins[] = {3, 5, 6, 9, 10, 11};
uint8_t boards_servopins[] = {9, 10};
uint8_t boards_i2cpins[] = {SDA, SCL};
Don't mess with these! Change only the digital IO pins array!
Once you know everything is working, set "#define WAITFORSERIAL true" to false so you don't have to open
the serial console to have the Firmata code run!
Once you connect in Pin IO mode you can see a stream of commands that are received and acted upon
The app and sketch are also 'smart' in that when you connect, the app will query the Arduino what pins are available
and what they can do!
Initial Query
Make sure you have the most recent version of the app, and the correct configuration. During connection you'll see the
app Querying Pin Capabilities... It will then get the correct details and fill out the pin map
Digital Input
All of the pins default to digital inputs with built-in pullup resistors. This means that by default the pins read HIGH. When
a button is wired to the pin & pressed or the pin is shorted to ground, you will receive a LOW signal
PWM Output
On some pins, there's PWM output available, you can dim or brighten an LED. You could also control a DC motor
through a driver, if it can be PWM controlled
Cycle Bluetooth
Turn your mobile device’s Bluetooth radio off and on again via your device's Settings app.
Cycle Power
Restart your mobile device by powering it off and restarting.