🛠 Périphérique BLE : pont série air ↔ USB (Bluefruit)

Adafruit Feather nRF52840 Express · intermediaire · Schéma : IMG-nrf52840-feather-intermediaire-1-nrf52840-ble-peripheral-bluefruit.svg — Feather nRF52840 advertised « Feather52840 », smartphone avec l'app Bluefruit LE Connect UART, flèches de données bidirectionnelles vers le port USB.

Objectives

Create a BLE peripheral using the Nordic SoftDevice stack via Bluefruit52Lib (Adafruit nRF52 core): the Nordic UART Service (NUS) acts as a bridge between a phone (Bluefruit LE Connect app) and the USB serial port. Understand advertising, connection, and the key constraint: the SoftDevice has higher priority than all user code when the radio is running.

Hardware

Complete Code

// nrf52840-ble-peripheral-bluefruit.ino — inspire de l'exemple officiel bleuart
#include <bluefruit.h>

BLEUart bleuart;  // service Nordic UART (caracteristiques RX/TX)

void setup {
  Serial.begin(115200);              // console USB CDC
  Bluefruit.begin;                 // demarre la SoftDevice (orchestree FreeRTOS)
  Bluefruit.setTxPower(4);           // jusqu'a +8 dBm sur le module MDBT50Q
  Bluefruit.setName("Feather52840");
  bleuart.begin;
  Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
  Bluefruit.Advertising.addService(bleuart);
  Bluefruit.Advertising.start(0);    // advertising illimite
}

void loop {
  if (bleuart.available)           // telephone -> carte -> USB
    Serial.write((uint8_t)bleuart.read);
  if (Serial.available)            // USB -> carte -> telephone
    bleuart.write((uint8_t)Serial.read);
}

Expected Verification

In Bluefruit LE Connect, the device “Feather52840” appears, the connection succeeds, and the UART page displays what you type in the USB monitor — and vice versa. The board’s NeoPixel blinks blue upon connection (BSP status behavior).

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials