Custom Bluetooth Low Energy (BLE) UART service examples for STM32WB15 and STM32WB55 microcontrollers.
Build your own custom BLE GATT profile on top of the STMicroelectronics STM32WB wireless MCU family, using practical firmware examples for both a small bare-metal device and a larger FreeRTOS-based target.
Read the full technical article · Visit A Blue Thing In The Cloud · YouTube channel
This repository shows how to create a custom BLE peripheral device using the STM32WB15 and STM32WB55 wireless microcontrollers from STMicroelectronics.
The examples implement a simple but useful BLE UART-style service with two custom GATT characteristics:
| Characteristic | Direction | BLE property | Purpose |
|---|---|---|---|
| RX | Central → STM32WB | Write | Receives data sent by the BLE central device |
| TX | STM32WB → Central | Read + Notify | Sends data back to the BLE central device |
The demo firmware implements an echo application: when a BLE central writes data to the RX characteristic, the STM32WB device sends the same data back through the TX characteristic.
This makes the project a practical starting point for custom BLE products such as:
- Wireless sensors
- BLE configuration interfaces
- Mobile-app-controlled devices
- Industrial BLE peripherals
- Low-power connected products
- Custom GATT services for embedded systems
STM32WB-custom-ble-examples/
├── STM32WB15_BLE/ # STM32WB15 custom BLE UART example
├── STM32WB55_BLE/ # STM32WB55 custom BLE UART example
└── README.md
| Example | Target board / MCU | Firmware style | Description |
|---|---|---|---|
STM32WB15_BLE |
STM32WB15CC Nucleo / STM32WB15CCU6 | Bare-metal style application | Custom BLE UART service for the smaller STM32WB15 device |
STM32WB55_BLE |
STM32WB55 Nucleo Pack | FreeRTOS-based application | Custom BLE UART service for the larger STM32WB55 device |
Both examples expose the same custom BLE UART-style service and are designed to help you understand how to add your own services and characteristics to an STM32WB BLE peripheral.
The original examples were created and tested with:
| Tool | Version |
|---|---|
| STM32CubeIDE | 1.9.0 |
| STM32CubeWB Firmware Package | 1.13.2 |
| Language | C |
| Connectivity | Bluetooth Low Energy |
Newer STM32CubeIDE and STM32CubeWB versions may work, but depending on ST middleware changes you may need to update generated files, linker scripts or middleware configuration.
The example implements one custom service with two custom characteristics:
Custom UART Service
├── RX Characteristic
│ └── Write property
└── TX Characteristic
├── Read property
└── Notify property
The RX characteristic is written by the BLE central device. In a real product, this is where you would receive commands, configuration packets or application data.
The TX characteristic is used by the STM32WB device to send data back to the central device. It supports both:
- Read, so the central can read the latest value.
- Notify, so the central can automatically receive new values when they are updated.
The example sets the RX and TX characteristic maximum length to 64 bytes.
The characteristic length definitions are located in:
Services/Service_UART.h
Look for:
SERVICE_UART_UART_RX_LONG_MAX
SERVICE_UART_UART_TX_LONG_MAXThe example notes that these values should not exceed 248 bytes.
The most relevant files for understanding and adapting the custom BLE service are:
| File | Purpose |
|---|---|
STM32_WPAN/App/app_ble.c |
BLE stack initialization and BLE application setup |
Configuration/Device_Configuration.h |
Device-level configuration, including BLE advertising name |
Services/Service_UART.h |
Custom service UUIDs, characteristic UUIDs and public service definitions |
Services/Service_UART.c |
Custom BLE service implementation, GATT service creation, characteristic creation and event handling |
The full technical explanation is available in the companion article:
Custom BLE profile on STM32WB microcontrollers
The BLE application flow is:
- The STM32WB initializes the BLE stack.
- The firmware registers the custom UART service handler.
- The custom BLE service is added to the GATT database.
- The RX and TX characteristics are added to the service.
- The device starts advertising.
- A BLE central device connects to the STM32WB peripheral.
- The central writes data to the RX characteristic.
- The firmware receives the write event.
- The demo echoes the received data back through the TX characteristic.
In the demo application, the echo behavior is implemented through:
void Service_UART_Test_Echo(const uint8_t *pData, uint8_t nData);For your own product, this is the kind of location where you would replace the echo logic with your real application logic.
git clone https://github.com/abluethinginthecloud/STM32WB-custom-ble-examples.git
cd STM32WB-custom-ble-examplesOpen the example that matches your hardware:
STM32WB15_BLESTM32WB55_BLE
In STM32CubeIDE:
- Import the selected project.
- Clean the project.
- Build the project.
- Check that the firmware compiles without errors.
Connect your STM32WB development board and flash the generated firmware using STM32CubeIDE.
Use a BLE central device such as a smartphone BLE scanner application.
Recommended test flow:
- Power or reset the STM32WB board.
- Scan for BLE devices.
- Connect to the STM32WB peripheral.
- Discover the custom UART service.
- Subscribe to notifications on the TX characteristic.
- Write sample data to the RX characteristic, for example:
20 21 22
- The same data should be received back through the TX characteristic.
The advertising name is configured in:
Configuration/Device_Configuration.h