ESP32 BLE Server and Client Communication Setup
Configuring an ESP32 BLE server and client architecture enables low-power local wireless communication for smart wearables, field diagnostic tools, and mobile sensor links. Understanding GATT profiles, services, and characteristics is essential for building stable Bluetooth links.
1. Understanding the GATT profile hierarchy
Bluetooth Low Energy uses the Generic Attribute Profile (GATT) hierarchy. A peripheral device acts as a GATT Server, advertising one or more Services. Each Service contains multiple Characteristics that hold raw sensor byte arrays or command parameters identified by custom 128-bit UUIDs.
2. Initializing a GATT server on ESP32
To broadcast data from an ESP32 to mobile devices (via apps like nRF Connect) or other microcontrollers:
- Initialize the BLE device with
BLEDevice::init("SensorNode"). - Create a GATT Server and assign a Service UUID using
pServer->createService(SERVICE_UUID). - Add a Characteristic with read, write, and notify properties (
BLECharacteristic::PROPERTY_NOTIFY). - Attach the
BLE2902descriptor to support client-subscribed push notifications.
3. Connecting central client ESP32 nodes
For device-to-device setups, configure the receiving ESP32 as a BLE Client. The client scans the 2.4GHz spectrum for matching Service UUIDs, establishes an active connection, and registers callbacks on characteristic value changes. For board performance comparisons, see our guide on ESP32 vs ESP8266 development[cite: 2].
4. Managing MTU sizes and notification throughput
Default BLE MTU (Maximum Transmission Unit) sizes limit packet payloads to 20 useful data bytes. Requesting an MTU exchange up to 512 bytes with BLEDevice::setMTU(512) significantly improves data throughput when streaming continuous telemetry.
When to get help
If you'd rather have this handled directly, see our Custom IoT & BLE Development Services for scope and turnaround times.