🛠 Le Bluetooth Low Energy embarqué, vu depuis le croquis
Objectives
Use the Bluetooth Low Energy module integrated into the Tian — the board was announced as a pioneer: it was one of the first Arduinos with embedded BLE. Typical architecture of the board: the radio module is on the Linux side, and the sketch accesses it through the Bridge. You will list the BLE peripherals visible from the SAMD21, then decide which side of the board deserves this work.
Hardware
- 1 powered Arduino Tian, Linux boot completed, network not required (BLE is standalone)
- 1 smartphone with a public advertising BLE sensor (or a beacon, or the Arduino Nano 33 BLE application which broadcasts)
- SSH access for the low-level diagnostic phase
Complete code
// Demander à Linux son environnement BLE via le Bridge.
#include <Bridge.h>
void setup {
Serial.begin(9600);
while (!Serial) { }
Bridge.begin;
delay(2000); // laisser le service BLE côté Linux s'initialiser
}
void loop {
// L'API dédiée au BLE passe par le Bridge de la Tian.
// >
// (getBLE / exemples d'usine du package de carte) : valider avec
// l'exemple BLE fourni, la doc officielle archivée étant la référence.
BridgeProcess p = Bridge.runShellCommand("hcitool lescan --duplicates");
// Lecture non bloquante de la sortie du scan côté Linux.
String line;
while (p.available && (line = p.readStringUntil('\n')).length) {
Serial.println(line); // adresse + nom des périphériques détectés
}
delay(10000);
}
Expected verification
The Serial Monitor displays lines like “AD:RS:ES:S1:BL:E Device-Name” as scans proceed: the SAMD21 has just made the Linux BLE stack work without knowing a single thing about radio. Turn off the sensor: it disappears from subsequent scans.
Common errors
- hcitool missing from the image:
opkg update && opkg install bluez-libs bluez-toolsvia SSH; depending on Linino versions, the tool may have a different name. > - Pasting Yun example code onto the Tian: the Bridge libraries differ, compilation may pass but behavior is not guaranteed.
- Wanting real-time BLE via the Bridge: the chain sketch -> UART -> Linux -> BLE stack introduces latency; for HID or reactive connected devices, use a native BLE board (Nano 33 BLE) and keep the Tian for the gateway.
- Forgetting WiFi/BLE coexistence: both share the SoC's 2.4 GHz radio; in saturated environments, long-duration scans degrade WiFi throughput.
- Leaving an active scan running without limit:
--duplicates+ infinite loop consumes Linux CPU; pace your scans and kill your processes cleanly. - Security: do not broadcast clear-text identifiers in an advertising name, it is read by the whole neighborhood.
Other tutorials for this board
- Découvrir l'Arduino Tian : un microcontrôleur et un vrai Linux sur la même carte
- Bouton et LED sur les GPIO de la Tian : les bases côté SAMD21
- Lire un capteur avec l'ADC 12 bits du SAMD21
- Le Bridge : faire exécuter des commandes Linux depuis le croquis
- Configurer le WiFi et piloter Linino en SSH
- Télémétrie : pousser une mesure du capteur vers le réseau
Code examples for this board
clignotant-rest.inoArduinoconsole-bridge.inoArduinovaleurs-partagees.inoArduinoprocess-shell.inoArduinoserveur-json.inoArduinolecture-fichier.inoArduino