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.
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.
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.
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.
Below is Arduino code:
Use points to gain access. You can either purchase points or contribute content and use contribution points to gain access.
Thanks for sharing!
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.
Nice article. Better with more complicated design.
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
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