ble_service.ino
The BLE radio (NINA module) advertises a custom F0F0 service with a notify characteristic carrying temperature in tenths of a degree. From the nRF Connect app the value updates live — the pattern behind every Arduino wireless sensor.
Hardware
An Arduino Nicla Vision (STM32H7 M7+M4, 23×23 mm) with GC2145 camera, LSM6DSOX IMU, PDM mic, ToF (VL53Lx), ESP32 Wi-Fi/BLE module and RGB LED (LEDR/G/B). The board alone; a smartphone with nRF Connect or LightBlue to read the characteristic.
Wiring
No wiring. Replace the simulation with a real sensor (I2C or 0-3.3 V on A0 = pin 15) for true temperature.
How it works
BLE.begin powers the radio; service and characteristic are declared before advertise; writeValue fires a notification to subscribed clients. BLE.poll runs the stack.
Running it
Programmed from the Arduino IDE (ArduinoCore-mbed, NICLA_VISION target) over USB-C; Camera, PDM, Arduino_LSM6DSOX, WiFiNINA and ArduinoBLE libraries provided.
Variants
Add several characteristics (humidity, RSSI), enable pairing, or run BLE and Wi-Fi together as a sensor-to-cloud gateway.
ble_service.ino
// Périphérique BLE : service custom + caractéristique notify
// portant la température (ici simulée, à câbler sur un capteur).
// Bibliothèque ArduinoBLE du core.
#include <ArduinoBLE.h>
BLEService surveillance("F0F0");
BLEIntCharacteristic temperature("F0F1", BLENotify | BLERead);
void setup() {
Serial.begin(115200);
if (!BLE.begin()) {
Serial.println("Radio BLE indisponible");
while (1) { ; }
}
BLE.setLocalName("NiclaVision");
BLE.setAdvertisedService(surveillance);
surveillance.addCharacteristic(temperature);
BLE.addService(surveillance);
temperature.writeValue(210); // 21,0 °C en dixièmes
BLE.advertise();
Serial.println("BLE « NiclaVision » diffusé");
}
void loop() {
BLE.poll(); // sert la pile BLE
static unsigned long t = 0;
if (millis() - t > 2000) { // rafraîchit toutes les 2 s
t = millis();
int dixiemes = 200 + random(0, 50); // simulation capteur
temperature.writeValue(dixiemes);
}
}