Connectivity of the Internet of Things

Pages
Contributors: RBERLIA
Favorited Favorite 26

Bluetooth

alt text

Here we will discuss the evergreen Bluetooth Classic radio, as well as the new and coming Bluetooth Low Energy (BLE), which is specifically designed around low-powered devices used in IoT.

Our discussion will be more focused on the BLE part. For a general overview of Bluetooth Classic, check out this awesome tutorial covering the basics of the technology:

Bluetooth Basics

An overview of the Bluetooth wireless technology.
Like other radio technologies. Bluetooth uses the 2.4GHz spectrum in the ISM band. It has a range from 10m up to 100m (at higher transmit powers, and that means higher power consumption!). Bluetooth is again an ad-hoc type of network and provides point to point (P2P) connections.

Bluetooth Classic supports up to one master and seven slaves in one piconet. It also follows the star network topology, which means that other peripherals cannot talk to each other.

A few key things to note are: A master in one piconet cannot be a master in another but a master in one piconet can be a slave in another. Bluetooth Classic can be used to transmit audio, data but not video.

We will now focus our discussion on the BLE protocol and how Bluetooth has evolved because of this technology.


Three Flavors of Bluetooth

Bluetooth Low Energy is a complete divergence from Bluetooth Classic radio. It was designed with a new protocol stack, new profile architecture and to specifically be able to run on low-power sources such as a coin cell battery.

We need to understand that this radio technology has not taken over or replaced the existing Bluetooth Classic radio. This has led to a species of different flavors of Bluetooth, which correlate with each other.

alt text

Bluetooth technology can be classified into three types of devices:

  • Bluetooth Classic -- The traditional Bluetooth having a higher throughput, mostly used for wireless audio and file transmission. The 'classic' radio has support for Bluetooth Smart.
  • Bluetooth Smart -- Bluetooth Low Energy has been branded as Bluetooth Smart and transmits just state information. It was designed specifically for applications with low-duty cycles (i.e., the radio is effectively on for a short period of time). Bluetooth Smart devices cannot communicate with Bluetooth Classic devices.
  • Bluetooth SmartReady -- These devices are essentially the "hub" devices such as computers, smartphones, etc. They support both the "classic" and "smart" devices, just as our smartphones can connect to a Bluetooth speaker to transmit audio and also communicate to a fitness tracker.

Classic vs. Low Energy

BLE uses the same 2.4GHz ISM band as other wireless protocols. In contrast to Bluetooth Classic's 79, 1MHz wide channels, Bluetooth Low Energy just has 40 Channels, which are 2MHz wide.

alt text

BLE also uses a 1Mbps GFSK modulation, which gives it a higher range than Bluetooth Classic.

BLE uses an adaptive frequency-hopping algorithm to hop amongst the available channels, where only a subset of available frequencies are used and it can quickly recover from loss of packets due to a bad channel. This technique ensures lower energy consumed in the radio. Bluetooth Classic uses a pseudo random hope sequence, changing the transmission frequency 1,600 times a second.

One main thing to note is that BLE allows up to 128 devices to be connected to a single master, in contrast with just seven in classic.

BLE compared with other wireless protocols in respect to wireless application

alt text


BLE Stack

The BLE stack was specifically designed with low-powered applications in mind.

alt text


The core of BLE rests in the GAP and GATT profiles. We will limit our discussion to just these today.

Think of Generic Access Profile (GAP) and Generic Attribute Profile (GATT) as analogous to the basic way we communicate and network with the people around us. When you meet someone, you may announce yourself and offer basic information about yourself. If you want to connect with that person, you then exchange other personal information, such as a phone number or email address, to be able to communicate. You no longer need to identify or announce yourself when you meet the person again and can start sharing other information. GAP is the initial meeting phase, when you introduce yourself, and GATT is the phase when you establish a connection with the person and start communication.

Generic Access Profile (GAP)

The GAP defines the mechanisms a BLE device can use to communicate with the outside world.

Advertising

In this phase the device can be in either of the two phases:

  • Broadcasting Phase: Where the device broadcasts public advertising data packets such as device name, signal strength, manufacturing details, etc.
  • Observing Phase: Where the device listens to the advertising packets. There is still no connection between the devices. There can be more than one device observing the same advertiser.

In the process of establishing connection, the devices also assume roles, namely:

  • Peripheral: The broadcasting device assumes the role of the peripheral, forming a pseudo connection to the device and responding to connection request of the central device to provide it with more information before connecting.

  • Central: The observer, when initiating a connection to the advertising device, assumes the role of central device. It can also be considered the master and can connect to more than one peripheral at a time.

Once the connection is established between the peripheral and central devices, the advertising packet is no longer sent. Now the GATT profile has to be utilized to communicate in both directions.

Generic Attribute (GATT) Profile

GATT profile defines the way two BLE devices communicate with each other using attributes such as services and characteristics, which are defined in the attribute protocol.

Similar to GAP, there are certain defined roles that the communicating devices assume:

  • Client: Usually, the central device assumes the role of the client. It typically sends a request to the GATT server. It can read and/or write attributes in the server.
  • Server: Usually, the peripheral assumes the role of the server. It is called the server as it stores these attributes. The server responds to client request and sends the required attributes to it.

Peripheral or central can both act as a server or client, depending on the data flow.

When the connection is being established the central and peripheral decide upon a "connection interval," which is the time between different connection events.

Further information can be found on the Bluetooth SIG pages listed below:


You can go through the following tutorials and blog posts we already have on Bluetooth and BLE, to get a better understanding of using them directly into your Bluetooth-based IoT project.

RN-52 Bluetooth Hookup Guide

A hookup guide to get you started with the RN-52 Audio Bluetooth Module Breakout Board.

Understanding the BC127 Bluetooth Module

SparkFun has two boards using the BC127; here's what you need to know to use them.