Bluetooth
Bluetooth is a short-range wireless technology standard used for exchanging data between fixed and mobile devices over short distances using ultra-high frequency (UHF) radio waves, from 2.402 GHz to 2.48 GHz. Bluetooth uses low-power transmission which gives it a very short range of up to 10 metres but with the benefit of low battery power consumption.
Bluetooth and Wi-Fi are similar in that both are used to exchange data between devices. The difference is that Wi-Fi is access point-centered, with all traffic routed through the access point, while Bluetooth is symmetrical, with data exchanged directly between two Bluetooth devices. Bluetooth serves well in simple applications where two devices need to connect without a dependency on additional devices such as those required for a WiFi access point.
While Ethernet, WiFi, and cellular connections are networking protocols and can be used for data transfer across large networks, Bluetooth is a device-to-device communication protocol, not a networking protocol.
Bluetooth is widely used to exchange files between two devices and connect smartphones to audio playback systems such as headphones, eliminating the need for wires. Bluetooth is also used to connect smartphones to Arduino circuits and IoT appliances to send control signals over a very short distance.
There are two variants of Bluetooth:
Classic Bluetooth
This is the original version of Bluetooth with a limitation that it can only have two devices connected and communicating with each other at one time.
To overcome these limitations and to improve its capability a newer version of Bluetooth (BLE) was introduced which is soon likely to become the de-facto standard.
Bluetooth Low Energy (BLE)
Bluetooth Low Energy is called so because it is a variant of Bluetooth that conserves energy by remaining in sleep mode constantly except for when a connection is initiated, unlike classic Bluetooth that is always on. This makes BLE particularly suitable for IoT applications where the sensors and devices sending data need a longer battery life.
BLE is not simply an upgrade to Bluetooth Classic, it is a different protocol altogether. It is meant for scenarios where you need to exchange small packets of data infrequently (such as sending sensor data to an app at periodic intervals), as against exchanging large amounts of data over a continuous connection (such as streaming music from your smartphone to a speaker), which is better achieved by Bluetooth Classic.
BLE also supports broadcast communication in addition to point-to-point communication.

Central and Peripheral Devices
BLE devices operate and interact with each other in one of two roles: Central or Peripheral.
-
Central Device: Central devices are generally the processing devices with higher computing power, more memory, and more battery power. Central devices are responsible for initiating connections to peripheral devices. For example, your smartphone is often a central device which connects to and reads data from BLE peripherals such as sensors connected to a BLE-enabled Arduino board.
-
Peripheral Device: Peripheral devices advertise their presence and availability to send data to central devices and wait for a connection to be initiated by a central device. Peripheral devices generally have lesser resources (computing power, memory, battery power) compared to central devices
A Central Device can connect to multiple Peripherals simultaneously and a Peripheral can connect to multiple Central Devices simultaneously.
Peripheral Services and Characteristics
BLE uses a concept of Services and Characteristics to manage data exchange between devices.
A service is a logical grouping of related data points provided by a peripheral device. For example, a weather monitoring sensor (peripheral) could have a service that provides temperature, humidity, and wind speed data. All peripherals could have a service that provides data related to battery level and energy consumption.
Each service has one or more characteristics, which are the individual data points provided by the service. In the weather monitoring service, temperature, humidity, and wind speed would be the characteristics. And in the battery information service, battery level and energy consumption would be the characteristics. Data is read from or written to a characteristic.
There are some standard services and characteristics that many commonly used devices use so that any central device can connect to it and know what data it can expect. You can also specify custom services and characteristics.
Universally Unique Identifiers (UUIDs)
Services and characteristics have what are known as Universally Unique Identifiers (UUIDs). A UUID is a universally unique 128-bit number which has a specific format as shown below:
55072829-bc9e-4c53-938a-74a6d4c78776
If your solution is expected to work in the public domain, you will have to ensure the UUIDs you use are indeed unique. If your solution is expected to work in a private domain you can generate UUIDs using an online generator.
Advertising and Connection Modes
-
A peripheral starts off in the advertising mode making it discoverable by central devices. In the advertising mode, the peripheral device periodically broadcasts advertising packets. These packets contain information about the peripheral’s identity, services, and characteristics. Central devices continuously scan for these advertising packets to discover nearby peripherals. In advertising mode, the peripheral device is not actively connected to any central device. It remains in a low-power state while broadcasting advertising packets, waiting for a central device to establish a connection.
-
The peripheral goes into the connection mode once a central device successfully establishes a connection with it. In this mode, central devices can read data from and write data to the peripheral device. The peripheral goes back to the advertising mode when the central device disconnects from it.
Notify
The BLE specification includes a mechanism known as notify. When notify on a characteristic is enabled and the sender (peripheral) writes to it, the new value is automatically sent to the receiver (central device), without the receiver explicitly issuing a read command. There’s a variation on this specification called indicate which works similarly, but in the indicate specification, the receiver sends an acknowledgment of the pushed data.
The client-server structure of BLE, with the central device acting as the client and the peripheral acting as the server, combined with the notify characteristic, is referred to as a publish-and-subscribe model. This is simlar to the concept used in MQTT or other messaging architectures.