🛠 Piloter une LED par Bluetooth LE avec le SDK nRF5
The objective
ble_app_blinky is Nordic's educational example: a custom GATT service with an LED characteristic (write) and a Button characteristic (notification). You write from the phone, and the card's RGB LED lights up; you press the user button, and the phone receives the notification. This is the best exercise for understanding write/notify before writing your own service.
Step 1 — Compile for the board
The MakerDiary repository ports the nRF5 SDK examples (17.0.x, SoftDevice S140 6.1.1) to the board:
git clone https://github.com/makerdiary/nrf52840-mdk.git
cd nrf52840-mdk
make BOARD=nrf52840_mdk -C examples/nrf5-sdk/ble_app_blinky/s140/nrf52840
The application hex file appears in _build/ble_app_blinky_nrf52840_mdk.hex. If compilation fails, check the SDK version and the gcc-arm-none-eabi version expected by the Makefile — the repository has not been updated since 2021.
Step 2 — Merge SoftDevice + application
Drag-and-drop requires a single image; forgetting this step results in a board that flashes but broadcasts nothing (issue #31):
mergehex -m s140_nrf52_6.1.1_softdevice.hex \
_build/ble_app_blinky_nrf52840_mdk.hex \
-o firmware.hex
Drop firmware.hex onto the DAPLINK drive, then press Boot/Reset.
Step 3 — Control from nRF Connect
- Install nRF Connect for Mobile (not Toolbox: here we want raw GATT access).
- Scan and connect to the
DKperipheral. - Expand the custom service: the LED characteristic accepts writes — send
01to turn the LED on,00to turn it off. - Enable notifications on the Button characteristic, press the user button on the board: the value changes in the app.
What you master afterwards
- Custom services and characteristics: 128-bit UUIDs, read/write/notify properties,
ble_evt_tcallbacks on the board side. - The DAPLink CDC port (115200 baud) displays BLE stack logs for debugging.
- The RGB LED and the button are standard P0 pins: refer to the official pinout diagram PDF, do not hardcode pins.
nRF5 SDK or nRF Connect SDK?
The nRF5 SDK is legacy; for a new project, Nordic promotes NCS (Zephyr-based). nrf52840_mdk is an upstream Zephyr board — NCS-compatible builds are done via MakerDiary guides, but the board is not explicitly listed in Nordic's documentation. The modern equivalent of the sample is samples/bluetooth/peripheral_blinky in the Zephyr tree.