In the previous blog “IoT Connectivity Technologies” we described in brief various wireless connectivity options available for developing an IoT device. In this blog, we will discuss in detail about the Bluetooth Technology – Physical and higher network layer and its classifications.

Bluetooth technology Introduction

Bluetooth is wireless technology standard using short wavelength Ultra High frequency radio waves in the license free Industrial, Scientific and Medical (ISM) frequency band. Bluetooth is managed by Bluetooth SIG (Special Interest Group) originally formed by five companies Ericsson, Nokia, IBM, Toshiba and Intel. The Bluetooth SIG will publish and update the Bluetooth specifications. The IEEE standardized Bluetooth as IEEE 802.15.1, but no longer maintains the standard. The Bluetooth radio interface enables reliable communications over short distances. It supports multiple channels with different power level and reliable forms of modulation.

Bluetooth Technology Basics

Bluetooth frequencies are located within the 2.4GHz ISM band. The frequency in ISM bands ranges from 2400MHz to 2483.5MHz. There is 1MHz space between each Bluetooth channel starting from 2402MHz and ending at 2480MHz. This can be calculated as 2401 + n, where n ranges from 1 to 79. This type of channel arrangement gives a guard band of 2MHz at the bottom end and 3.5MHz at the top, thus preventing interference. Bluetooth employs a technology called Frequency Hopping Spread Spectrum by which the radio signals are transmitted by rapidly switching the carrier signal among various frequency channels.  In this method the transmitted data is divided into packets and sent on one of 79 designated channels switched randomly at a rate of 1600 times per second. The main drawback of this technique is the occurrence of collision with another wireless device such as Wi-Fi when introduced into the same environment. To avoid this, the Adaptive Frequency hopping technique is introduced. The Adaptive Frequency Hopping technique allows the Bluetooth to adapt the environment by excluding the fixed sources of interference (i.e. bad channels) from the available list of channels. This technique of re-mapping reduces the number of channels to be used by the Bluetooth. The following figure illustrate the collision resulting from the random frequency hopping adapting to the environment

Collision in Random Frequency hopping

Random Frequency Hopping

The following figure illustrate the collision avoided using Adaptive Frequency Hopping

Advantage of Adaptive Frequency hopping

Adaptive Frequency Hopping

The digital data is conveyed using a modulation scheme called Gaussian Frequency Shift Keying. In this technique the bits of the transferred data corresponds to discrete frequency changes in the carrier signal. The binary one is represented by a positive frequency deviation and a binary zero is represented by a negative frequency deviation. With this technique, the basic data rate (BR) of 1 Mbps is achieved. To achieve higher data rates, Bluetooth uses another major class of modulation technique called Phase Shift Keying. Phase Shift Keying is a type of digital modulation scheme by which the digital data is conveyed by modulating the phase of the carrier wave. π/4 Differential Quadrature Phase Shift keying (π/4-DQPSK) and 8-ary Phase Shift Keying (8DPSK) are the different forms of PSK used for enhanced data rate (EDR) capability. By these techniques the Bluetooth can achieve data rate of 2Mbps with π/4-DQPSK and 3Mbps with 8DPSK. The combination of these BR and EDR mode is classified as a “BR/EDR radio”. Further improvement in the Bluetooth data rate up to 24 Mbps is achieved without changing the format of the Bluetooth modulation but by operating cooperatively with an IEEE 802.11g physical layer. Bluetooth Low Energy, a version of Bluetooth technology focused on low energy consumption than higher data rate also operates in the same frequency range of 2.4GHz to 2.4835GHz. Instead of the 79 1MHz channels, BLE has 40 2MHz channels and the data is transmitted using Gaussian Frequency Shift Keying. The bit rate of the BLE is 1Mbps similar to the Basic Rate (BR). With understanding of the physical layer, we will now explore the higher communication layers.

Bluetooth Communication

Bluetooth communication takes place a short range ad hoc network known as Piconet. A Piconet starts with two connected devices and can grow up to eight connected devices. In general, the Bluetooth communication sets one of the Bluetooth devices as a controlling unit (master unit) and other device as a slave unit to follow the master. Each device added to the Piconet will be assigned with a specific time period to transmit the data without colliding or overlapping with the other units. Bluetooth core specification supports connection of two or more Piconets to form a scatternet by which a device of one Piconet either operating as a master or slave can simultaneously play a slave role in the other. Hence communication between more than 8 devices is made possible. The following figure depicts the concept of scatternet,

Bluetooth Communicaton

Concept of Scatternet

Bluetooth Classification

Number of Bluetooth versions is developed to meet the specific requirements of the time with the update of fixing the previous version errors. All the updated versions of Bluetooth support backward compatibility. The following table describes the different versions of Bluetooth available 

Bluetooth Versions

Bluetooth Classifications

Why there is so much hype on BLE?

Bluetooth Classic has faced critical challenges such as fast battery draining and frequent loss of connection which requires frequent pairing. BLE has ability to overcome these challenges and this is the reason why it has become popular in this decade. BLE is more intelligent in managing connections while preserving the battery power. BLE rather maintaining constant bit streams of information sends small chunks of data when required and goes to sleep during the idle periods. Bluetooth/BLE Low Energy comes under the Personal Area Network (PAN) type of connectivity. An IoT device that supports Bluetooth/BLE connectivity can use smart phones as a gateway to the internet. At present, most of the smart phones being launched are Bluetooth Smart Ready, i.e. devices that can communicate with both Bluetooth classic and Bluetooth Low Energy devices. Since smart phones have become the norm, most of the IoT device developments especially in healthcare, home automation segments take place centered around BLE connectivity. IoT devices that supports BLE connectivity tends to be a Bluetooth Smart device that can connect only with the Smart ready devices. Bluetooth smart devices such as smart watches, car key fobs, heart rate monitor are stand-alone, small batter operated that mainly focus on the power consumption as low as possible. With the understanding of the Bluetooth technology and its classifications, we will discuss in detail about the design considerations for developing IoT devices with Bluetooth Low Energy connectivity.

About Embien

Embien Technologies is a leading provider of embedded design services for the Semi-conductor, Industrial, Consumer and Health Care segments. Embien has successfully executed many projects like based on IoT such as healthcare Wearables, Gateways, and Data Analytics etc. Embien also offers a set of wearable design collections complete with electronics, firmware and Cloud that can be used to shorten product development costs and time significantly.

Freedom KL25Z from Freescale Semiconductor is a popular board based on KL25 ARM Cortex M0+ micro-controller. There are many tutorials and examples available for using many features of the FRDM-KL25Z board. This blog describes the implementation of USB host interface to support a low cost Bluetooth dongle along with 3-axis accelerometer and PWM features.

In the demo, an Android application will connect to the Bluetooth device connected to the FRDM board. After connection, the board will transmit its accelerometer reading to the application which will be used to render a 3D image of the board. Similarly the application can be used to drive the tri-color LED available with varying colors using PWM.
This blog will describe the hardware for the demo along with the necessary software implementation that can be customized for user’s applications such as for IoT, academics etc.
Bluetooth Stack over USB

Bluetooth connectivity for FRDM-KL25Z

Hardware Setup

Interfacing the Bluetooth USB dongle to the board is the important step for the demo. To enable using low cost devices, the demo uses low cost dongles available in local stores under 2 dollars. These devices generally uses CSR chipset module inside.

About connecting the dongle to the board, follow the procedure outlines in this MCUOnEclipse blog.

This link provides the detailed description of USB host mode hack for the FRDM KL25Z board. Another option is to modify header “J21” (Refer sheet3 in Freedom KL25Z schematics with document number SCH-27556 or SPF-27556).

For 3 Axis accelerometer support, the on-board MMA8451Q chip is used. It is connected to KL25 MCU via I2C interface. I2C0 port in pins PTE24 and PTE25 is used for the interface.

The on-board tri-color LED is utilized for PWM implementation. The Red LED of tri-color LED is connected to the PWM pin TPM2_CH0 of PTB18, Green LED is connected to TPM2_CH1 of PTB19 and blue LED is connected to TPM0_CH1 of PTD1.

S.NO Signal Name Pin Number
1 I2C0_SDA PTE25
2 I2C0_SCL PTE24
3 Red LED PTB18
4 Green LED PTB19
5 Blue LED PTD1

For this demo, the power to the board is provided through the openSDA USB Mini-B connector “J7”.

Software

The firmware initially prepares all the underlying hardware interfaces. The USB stack first prepares the USB OTG controller for host operation. Once done, it enumerates the attached device. Once a valid Bluetooth Dongle is detected, it configures the same and brings up the various layers of the Bluetooth stack like HCI, L2CAP, RFComm etc. Once a logical channel is established between the FRDM-KL25 board and dongle, the data is transferred in a custom format.

Upon detection of change in accelerometer reading, the 3 axis data is read and sent to the Android application over Bluetooth by adding a header field in the front and footer in the end. Up on recognizing the packet, the application calculates the position and renders the 3D image of the board in the display using OpenGLES routines.

Similarly on change of LED colour values by the user, the data is send in custom frame format to the board over Bluetooth. The firmware decodes the same and drives the 3 components of the LED in different brightness values using PWM modulation.

Demo

The demo of Bluetooth Stack on FRDM-KL25Z is available as a video in the below link.

Source Code of the project

All the necessary firmware to run in the FRDM board can be downloaded from our downloads page.

With Bluetooth, especially Bluetooth Low Energy (BLE) is being used more and more in IoT applications like activity trackers, health bands etc, such a stack will be an advantage when integrating the functionality on top of USB host using low cost USB dongles.

About Embien Technologies: Embien Technologies is a leading provider of embedded design services for the Semi-conductor, Industrial, Consumer and Health Care segments. Our extensive experience in working with wireless technologies like Bluetooth, Bluetooth Low Energy (Bluetooth Smart), RFID, ZigBee, WiFi etc enables us provide solutions to customer quickly at an unmatched quality at a very low price point. Feel free to contact us for any of your connectivity, OpenGL, mobile application or embedded product development requirements.

Freedom KL25Z from Freescale Semiconductor is a popular board based on KL25 ARM Cortex M0+ micro-controller. There are many tutorials and examples available for using many features of the FRDM-KL25Z board. This blog describes the implementation of USB host interface to support a low cost Bluetooth dongle along with 3-axis accelerometer and PWM features.

In the demo, an Android application will connect to the Bluetooth device connected to the FRDM board. After connection, the board will transmit its accelerometer reading to the application which will be used to render a 3D image of the board. Similarly the application can be used to drive the tri-color LED available with varying colors using PWM.
This blog will describe the hardware for the demo along with the necessary software implementation that can be customized for user’s applications such as for IoT, academics etc.
Bluetooth Stack over USB

Bluetooth connectivity for FRDM-KL25Z

Hardware Setup

Interfacing the Bluetooth USB dongle to the board is the important step for the demo. To enable using low cost devices, the demo uses low cost dongles available in local stores under 2 dollars. These devices generally uses CSR chipset module inside.

About connecting the dongle to the board, follow the procedure outlines in this MCUOnEclipse blog.

This link provides the detailed description of USB host mode hack for the FRDM KL25Z board. Another option is to modify header “J21” (Refer sheet3 in Freedom KL25Z schematics with document number SCH-27556 or SPF-27556).

For 3 Axis accelerometer support, the on-board MMA8451Q chip is used. It is connected to KL25 MCU via I2C interface. I2C0 port in pins PTE24 and PTE25 is used for the interface.

The on-board tri-color LED is utilized for PWM implementation. The Red LED of tri-color LED is connected to the PWM pin TPM2_CH0 of PTB18, Green LED is connected to TPM2_CH1 of PTB19 and blue LED is connected to TPM0_CH1 of PTD1.

S.NO Signal Name Pin Number
1 I2C0_SDA PTE25
2 I2C0_SCL PTE24
3 Red LED PTB18
4 Green LED PTB19
5 Blue LED PTD1

For this demo, the power to the board is provided through the openSDA USB Mini-B connector “J7”.

Software

The firmware initially prepares all the underlying hardware interfaces. The USB stack first prepares the USB OTG controller for host operation. Once done, it enumerates the attached device. Once a valid Bluetooth Dongle is detected, it configures the same and brings up the various layers of the Bluetooth stack like HCI, L2CAP, RFComm etc. Once a logical channel is established between the FRDM-KL25 board and dongle, the data is transferred in a custom format.

Upon detection of change in accelerometer reading, the 3 axis data is read and sent to the Android application over Bluetooth by adding a header field in the front and footer in the end. Up on recognizing the packet, the application calculates the position and renders the 3D image of the board in the display using OpenGLES routines.

Similarly on change of LED colour values by the user, the data is send in custom frame format to the board over Bluetooth. The firmware decodes the same and drives the 3 components of the LED in different brightness values using PWM modulation.

Demo

The demo of Bluetooth Stack on FRDM-KL25Z is available as a video in the below link.

Source Code of the project

All the necessary firmware to run in the FRDM board can be downloaded from our downloads page.

With Bluetooth, especially Bluetooth Low Energy (BLE) is being used more and more in IoT applications like activity trackers, health bands etc, such a stack will be an advantage when integrating the functionality on top of USB host using low cost USB dongles.

About Embien Technologies: Embien Technologies is a leading provider of embedded design services for the Semi-conductor, Industrial, Consumer and Health Care segments. Our extensive experience in working with wireless technologies like Bluetooth, Bluetooth Low Energy (Bluetooth Smart), RFID, ZigBee, WiFi etc enables us provide solutions to customer quickly at an unmatched quality at a very low price point. Feel free to contact us for any of your connectivity, OpenGL, mobile application or embedded product development requirements.