A Detailed Guide to Using Bluetooth in Arduino Ecosystem

Wireless Communication Protocols

Before delving into the world of Bluetooth, let’s first take a look at the various wireless communication protocols that are widely used in electronics these days. Here are some of the most common wireless communication protocols apart from Bluetooth.

Wi-Fi

Wi-Fi (Wireless Fidelity) is the most commonly used wireless communication protocol because of its ease of use and the fact that almost everyone around the world uses it. It can provide internet connectivity to devices present within a radius of up to 40 meters, using the IEEE 802.11 standard. It operates at a frequency of 2.4 GHz, providing a maximum speed of 600 Mbps. If we talk about Arduino, some boards have an in-built Wi-Fi connectivity option, while others need an external module such as the ESP8266 or the ESP32 modules.

ZigBee

Another popular wireless communication protocol, in the world of IoT and electronics, is ZigBee. It follows the IEEE 802.15.4 standard, providing wireless connectivity within a range of about 100 meters. The maximum data rate that it offers is 250 Kbps. Though the data rate is quite low, it offers an advantage of high security since it provides a 128-bit AES encryption. ZigBee is not a desirable wireless protocol when it comes to industrial applications, but it is a good choice if you are working on a small-scale project.

RFID

Another useful wireless communication protocol is Radio Frequency Identification (RFID), commonly used to read tags and bar codes. The range of RFID can be classified into two types – short-range and long-range. For short-range applications, it can send data over a distance of 10 cm, while it can provide connectivity over a span as long as 200 meters, for long-range applications. RFID is ideally used in projects involving attendance systems and tag readers. 

Cellular Networks

Cellular networks, as we all know them, are one of the best wireless communication protocols present in the world right now. It has evolved from the 2G network to 3G (HSPA) to 4G (LTE) and is now moving towards 5G. Cellular networks allow you to send large amounts of data over a high-speed connection. They use a frequency ranging from 900 MHz to 2.1 GHz and cover distances as long as 200 kilometers.

What Is Bluetooth Technology?

After looking at the various wireless communication protocols, let’s see what the Bluetooth technology is. It is used for transmitting data wirelessly, over short distances. It is popular for the high speed that it offers while consuming very low power. It follows the IEEE 802.15.1 standard to transfer data over a distance of up to 10 meters.

Bluetooth sends and receives data on a frequency band of 2.45 GHz, offering a maximum data rate of 721 kbps. It is usually used to connect portable devices such as mobile phones. If you have a device that supports Bluetooth connectivity, you can pair it up with 7 other devices at the same time. Isn’t that cool?

How Does Bluetooth Work?

Now, let’s see how does Bluetooth technology manage to offer so many benefits at the same time. Bluetooth allows a device to connect to a maximum of 7 other devices and transmit data to each one of them. It creates a Personal Area Network (PAN) within which communication takes place. The devices are connected in a master-slave configuration, where master device is the one which begins the communication process with other devices and also controls the communication process.

A slave device cannot communicate without the permission of its master device and it must synchronize its timings and hop frequency with that of the master device. The traffic within the Bluetooth network is managed and monitored by the master device.

The connection topology of Bluetooth is referred to as a Bluetooth piconet, where a master device connects to slave devices and transmits data. The connections between a master and its slaves exists until it is disconnected by the user or the devices travel out of the coverage range. The devices connect to each other via a Bluetooth pairing process, which is initiated by one of the devices.

Bluetooth pairing process is initiated when a device starts searching for other devices in its range. After it finds the desired device, it can initiate a request to connect to that device. Upon sending the request, the user will be prompted for a password or a passkey, that will allow the device to connect to each other. The passkeys on both ends must match, in order to connect the devices to each other.

Bluetooth Profiles

To understand Bluetooth technology better, you need to know what Bluetooth profiles are and how they function. A number of set specifications are defined in various Bluetooth profiles which allow different types of devices to communicate over a Bluetooth connection.

1.      Advanced Audio Distribution Profile (A2DP)

A2DP defines how to stream audio from a source to a sink.

2.      Audio/Video Remote Control Profile (AVRCP)

AVRCP allows a user to control all their devices (such as TVs, music players) through a single remote control.

3.      Basic Imaging Profile (BIP)

BIP determines how to transfer images from an imaging device and how to control it. Such a profile is suited for cameras and other devices that have cameras, such as smartphones.

4.      Basic Printing Profile (BPP)

BPP, as the name suggests, is used to send media such as images and text to printers.

5.      Common ISDN Access Profile (CIP)

CIP manages how ISDN traffic is sent over a Bluetooth connection.

6.      Cordless Telephony Profile (CTP)

As the name suggests, this profile determines how a cordless phone can be implemented over Bluetooth.

7.      Dial-up Network Profile (DUN)

DUN is used where Bluetooth is used to connect to the internet.

8.      Fax Profile (FAX)

Fax profile is applicable in scenarios where a device is made a fax gateway by another device, to send a fax. For instance, a smartphone can act as a gateway while sending a fax from a computer.

9.      File Transfer Profile (FTP)

FTP defines how two devices can send and receive files over a Bluetooth connection.

10. General Audio/Video Distribution Profile (GAVDP)

This profile is used to send audio/video files. The best example is a music player that sends audio files to a wireless headset over a Bluetooth connection.

11. Generic Object Exchange Profile (GOEP)

GOEP defines the exchange of objects between two devices over a Bluetooth connection.

12. Hands-Free Profile (HFP)

HFP defines how a device (gateway device) can receive and dial calls for another device (hands-free device).

13. Hard Copy Cable Replacement Profile (HCRP)

HCRP is used where wireless printing is required via printer drivers, over a Bluetooth connection.

14. Headset Profile (HSP)

HSP defines how a Bluetooth device connects with a headset.

15. Human Interface Device Profile (HID)

This profile defines how human interface devices such as keyboards, gaming devices and mice interact over a Bluetooth connection.

16. Intercom Profile (ICP)

ICP defines the interaction of two mobile phones over a Bluetooth connection.

17. Object Push Profile (OPP)

OPP defines how a push server and a push client work together.

18. Personal Area Networking Profile (PAN)

Personal Area Networking Profile defines how two or more devices can form a network via Bluetooth and communicate within it.

19. Service Discovery Application Profile (SDAP)

SDAP defines how a device can discover services on another device over a Bluetooth connection.

20. Service Port Profile (SPP)

SPP defines how virtual Bluetooth ports are made and how two devices can connect through them.

21. Synchronization Profile (SYNC)

Synchronization profile enables devices to share their addresses and other personal information.

22. Video Distribution Profile (VDP)

VDP defines how a device can access a video via a Bluetooth connection.

Uses of Bluetooth

Bluetooth has many different uses, as you may have guessed by looking at the huge number of profiles that are defined for Bluetooth communication. Here is a list of most common Bluetooth applications:

1.       Wireless keyboards

2.       Wireless mouse

3.       Wireless printers

4.       Cordless speakers

5.       Headsets

6.       Transfer of images, videos, and audio files. 

Using Bluetooth In Arduino

Using Bluetooth in Arduino can open doors to many possibilities. You can make a multitude of new and innovative projects by including a simple Bluetooth module in your list of project components. HC-05 is an external Bluetooth module that almost every other student and hobbyist uses to add Bluetooth connectivity in their Arduino project. You can configure it as either a master or a slave device. Let’s first look at the pin configuration of HC-05 and then see how to connect it to Arduino.

HC-05 has 6 pins namely status, RXD, TXD, GND, VCC and EN. For simply connecting a Bluetooth module to Arduino, we will use four pins – RXD, TXD, GND and VCC. You need to connect the RXD and TXD pins to the digital I/O pins of Arduino and the VCC pin to 5 Volts while the GND pin to the GND pin of Arduino.

You would need to define the TXD and RXD pins in your code and enable serial communication over these pins. You would have to include the SoftwareSerial.h library file for this code.

#include

SoftwareSerial MyBlue(2, 1); // RX | TX

 

void setup()

{

 

  Serial.begin(9600);

  MyBlue.begin(9600);  //Default Baud for comm, it may be different for your Module.

  Serial.println("Bluetooth is ready to connect.\n The pairing key is 0123");

 

}

 

void loop()

{

 

  // Feed any data from bluetooth to Terminal.

  if (MyBlue.available())

    Serial.write(MyBlue.read());

 

  // Feed all data from termial to bluetooth

  if (Serial.available())

    MyBlue.write(Serial.read());

}

 

This code allows you to connect your Bluetooth module to any other external device. You can define a passkey and allow other devices to connect to your Bluetooth module. This is a very simple program. You can alter this code according to your application and design your Bluetooth project as you like

Share this content