🛠 Piloter une LED par Bluetooth LE avec le SDK nRF5

nRF52840-MDK (boards.json id: nrf52840-mdk) · intermediaire · Un service GATT personnalisé, une écriture depuis le téléphone, et la LED de la carte s'allume — le BLE applicatif de bout en bout.

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

  1. Install nRF Connect for Mobile (not Toolbox: here we want raw GATT access).
  2. Scan and connect to the DK peripheral.
  3. Expand the custom service: the LED characteristic accepts writes — send 01 to turn the LED on, 00 to turn it off.
  4. Enable notifications on the Button characteristic, press the user button on the board: the value changes in the app.

What you master afterwards

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.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials