BLE GATT Profile: What It Is and How It Works
BLE GATT profile is a set of rules and data structures that define how devices communicate over Bluetooth Low Energy. It organizes data into services and characteristics so devices can exchange information in a standard way.How It Works
Think of a BLE GATT profile like a menu at a restaurant. The menu (profile) lists different categories of food (services), and each category has specific dishes (characteristics) you can order. When two devices connect, they use this menu to understand what information can be shared and how.
In BLE communication, one device acts as a server holding the data organized by services and characteristics. The other device acts as a client that reads or writes this data. This setup makes it easy for devices to talk to each other without confusion, even if they come from different makers.
Example
This example shows a simple BLE GATT server profile with a Heart Rate service and a characteristic for the heart rate measurement.
from bluepy.btle import Peripheral, UUID, Service, Characteristic # Define UUIDs for Heart Rate Service and Measurement Characteristic HEART_RATE_SERVICE_UUID = UUID('180D') HEART_RATE_MEASUREMENT_CHAR_UUID = UUID('2A37') class HeartRateService(Service): def __init__(self, peripheral): super().__init__(peripheral, HEART_RATE_SERVICE_UUID) self.heart_rate_char = Characteristic(self, HEART_RATE_MEASUREMENT_CHAR_UUID, properties=Characteristic.props['READ'] | Characteristic.props['NOTIFY']) # Simulate starting a BLE peripheral with Heart Rate Service peripheral = Peripheral() heart_rate_service = HeartRateService(peripheral) print(f"Service UUID: {heart_rate_service.uuid}") print(f"Characteristic UUID: {heart_rate_service.heart_rate_char.uuid}")
When to Use
Use BLE GATT profiles when you want devices to share data efficiently over Bluetooth Low Energy. For example, fitness trackers use the Heart Rate profile to send your pulse to your phone. Smart home devices use profiles to control lights or locks. Profiles ensure devices understand each other without custom coding.
They are essential in IoT projects where low power and standardized communication are important, like health monitors, wearable devices, and sensor networks.
Key Points
- A BLE GATT profile organizes data into services and characteristics.
- It defines how devices read, write, or get notified about data.
- Profiles enable interoperability between different manufacturers' devices.
- Common profiles include Heart Rate, Battery, and Device Information.