Develop a BLE application with Arduino and Bluefruit boards and Test with iphone LightBlue

Make it to the Right and Larger Audience

Blog

Develop a BLE application with Arduino and Bluefruit boards and Test with iphone LightBlue

Bluetooth low energy (BLE) is introduced as a light-weight subset of Bluetooth since Bluetooth 4.0. It originates from Nokia’s Wibree project and is quite different from Bluetooth by all means. There are many good BLE tutorials online and one of them is from Adafruit, https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gap.

When BLE peripheral device is powered up, it periodically sends out (advertises) advertising data. BLE central device listens (scans) for advertisement and acquires surrounding BLE peripheral devices’ characteristics. This procedure is shown below. Central device can also send “scan response request” message so peripheral can respond with more information with “scan response data”. At protocol layer, this advertising process is governed by the so-called GAP (Generic Access Profile) profile.

ble_arduino1

In advertising process, peripheral device is not “connected” to central device yet and its advertisement can be pick up by multiple central devices. To setup a one-to-one connection, peripheral and central devices need to go through the following procedure.

ble_arduino2

Once connection is up, devices follow below procedure to exchange data. Central device which is the master sends out request and peripheral device responds with response data. This process repeats per connection interval. What is not shown in the drawing is within one connection interval, master/slave can also exchange data multiple times.

ble_arduino3

The communication in this connected state is governed by GATT (Generic Attribute Profile) profile which makes use of a generic data protocol called ATT (Attribute Protocol). GATT defiles profiles, services, and characteristics to represent, store, and transmit data. A profile can have multiple services and a service can have multiple characteristics. Profile and service can be predefined by Bluetooth SIG or be defined by users. It is characteristics really holds data of interest. Each characteristic distinguishes itself via a 16bit or 128bit UUID.

With above fundamental information about BLE, let’s take a look of a simple BLE application using Arduino and Bluefruit. Arduino is a popular open-source microcontroller development platform and Bluefruit is an BLE board using Nordic nRF8001 developed by adafruit.

The connection of these two are shown as below.

ble_arduino4

Below is Arduino code:

The following is site premium content.
Use points to gain access. You can either purchase points or contribute content and use contribution points to gain access.
Highlights: 3661 words
 
Firmware engineer
Author brief is empty
Groups:

4 Comments
  1. echatterjee 2 years ago
    0
    -0

    Turns out having BLE working on Arduino is pretty simple thanks to the BLE library which does the heavy-lifting. For those who may wonder, the article uses a generic app on iOS and android to test the system.

    4
  2. jieFan 2 years ago
    0
    -0

    Nice article. Better with more complicated design.

    4
  3. Indeed! I found another good reference for BLE on Arduino. It is using the same Arduino UNO + Adafruit Bluefruit board setup but the firmware uses Adafruit BLE library instead of BLEPeripheral.
    https://create.arduino.cc/projecthub/audalogy/remote-controlled-car-pt-4-bluetooth-wireless-control-dd7ce4

    5
  4. ZakH 2 years ago
    0
    -0

    Good practical BLE dev tutorial. It is based on BLEPeripheral library. I can’t find a good tutorial about this library. Here is some resource about this lib with some simple example:
    https://www.arduino.cc/en/Reference/BLEPeripheralConnected

    5

Contact Us

Thanks for helping us better serve the community. You can make a suggestion, report a bug, a misconduct, or any other issue. We'll get back to you using your private message ASAP.

Sending

©2018  ValPont.com

Forgot your details?