Bluetooth Low Energy (BLE) is a wireless network technology used for sensor data and low-bandwidth applications where small amounts of data are transferred at lower speeds.
BLE was introduced in 2010. The original Bluetooth defined in the previous versions is referred to as Bluetooth Classic. BLE was not an upgrade to the Bluetooth Classic but rather it’s a new technology focused on the Internet of Things (IoT). BLE is sometimes referred to as "Bluetooth Smart".
BLE Terms & Definitions
A device that scans and originates connections to BLE peripherals in order to perform some operation. This is typically a mobile device but it can also be an embedded device like RAK4630.
A device that advertises its presence and accepts connections from a Central in order to accomplish some task.
When a BLE device wants to communicate its presence to other devices in the area, it broadcasts small packets of data which are called advertising packets or advertisements.
Generic Access Profile provides a framework that defines how BLE devices interact with each other.
The Generic Attribute Profile defines the format of the data exposed by a BLE device.
A collection of characteristics (data fields) that describes a feature of a device. For example the DIS (Device Information service) can contain a characteristic representing the serial number of the device.
An entity containing meaningful data that can typically be read from or written to.
A means for a BLE peripheral to notify the Central when a characteristic’s value changes. The central doesn’t need to acknowledge that it’s received the packet.
Same as an indication, except each data packet is acknowledged by the Central. This guarantees their delivery at the cost of throughput.
Universally unique identifier, 128-bit number used to identify services, characteristics and descriptors.
The Bluetooth Special Interest Group (SIG) manages publicly specified GATT services:
The Adafruit Bluefruit library library makes it easy to add Bluetooth Low Energy connectivity to your IoT project. Bluefruit offers common BLE services such as:
- Battery Service(BAS)
Send notifications about the battery level of the device.
- DIS (Device Information Service)
Provides generic information about the device. Such as: manufacturer name, model, serial number
- NUS (Nordic UART Service)
This is a proprietary service defined by Nordic Semiconductors that we can use as a baseline transport mechanism between BLE modules. You can use this service to send any kind of data from central to peripheral or vice versa.
But BLE opens up a world of endless possibilities by allowing developers to specify various custom profiles for different use cases. I decided to write this article because I can’t find good examples of custom profile BLE using Adafruit Bluefruit. If you want to create a new UUID for your application, follow the suggestion shown on the link below
- WisBlock Starter Kit with RAK4631 and RAK5005-O - https://store.rakwireless.com/products/wisblock-starter-kit
- Mobile with nrf Connect for Mobile application installed
Android - https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en_US&gl=US
IOS - https://apps.apple.com/us/app/nrf-connect-for-mobile/id1054362403
Install Arduino BSP for RAK4630
This guide requires the installation of an Arduino board support package. Follow the link below:
Testing Custom BLE sketch
Use the link below to download the sketch:
Follow these steps to upload your sketch:
- Attach the LoRa and BLE Antenna. Although this guide doesn't use LoRa it still needs to install the LoRa antenna.
- Connect your WisBlock Starter Kit to the PC using the USB cable.
- Launch Arduino IDE and choose File→Open and choose the path where you downloaded the sketch.
- On Arduino IDE and choose Tools→Board→ RAKwireless nRF modules→ WisBlock RAKwireless nRF modules →WisBlock Core RAK4631 Board to find your board in the Arduino menu.
- Choose the correct serial port for your board on Tools→Port.
- Finally, click the Upload button.
To check log messages of the application, open the Arduino Serial Monitor.
Now launch the nRF Connect application on mobile.
1. Press the SCAN button and search for RAK4630 on the device list. If you have a WisBlock Starter Kit connected, you can see the blue LED flashing while the BLE is disconnected.
Finally press the CONNECT button as shown in the right image below.
2. The blue LED turns off when the BLE connection is established.
To send a message via custom BLE service, select the CLIENT tab and click on Unknown Service. A new Unknown Service and Characteristic window will appear. Finally click on the highlighted up arrow icon.
3. A new Write value window will appear.
To turn off the WisBlock Starter Kit RAK5005-O Base board’s green LED, write 00 then click on the SEND button as shown on the left image. To turn on the green LED, write 01 then click on the SEND button as shown on the right image.
Use this example only as a reference to develop a more complete application.