clignotante.ino
The cloud-flavored blink: LED D7 blinks and two variables expose the state and counter to the Particle API. From the dashboard or curl, the board becomes remotely queryable with no extra network code.
Hardware
A Particle Boron module (nRF52840, Wi-Fi + Bluetooth LE, cellular variant where applicable) with on-board antenna. None: the user LED is built in. The module embeds the LiPo charger (LiPo pad) and antenna management.
Wiring
Nothing to wire for LED D7. Power: USB, LiPo or 3.6-5.5 V on VIN.
How it works
In loop() we toggle D7 and update the variables exposed by Particle.variable; the cloud stack serves them on a plain HTTP request to the Particle API.
Running it
Install the Particle CLI (particle setup), flash with particle flash --serial or OTA (particle flash <name> firmware.bin). The Device Cloud app or REST API complete the deployment.
Variants
Drive the LED remotely with Particle.function, or blink on cloud state (PARTICLE_CONNECTED) as a network indicator.
clignotante.ino
// Clignotement D7 + suivi cloud via Particle.variable.
// La LED utilisateur de la carte est sur D7.
int etatLed = 0;
unsigned long compteur = 0;
// Expose l'etat a l'API cloud : GET /v3/devices/<id>/variables/etat
Particle.variable("etat", etatLed);
Particle.variable("cycles", compteur);
void setup() {
pinMode(D7, OUTPUT);
Serial.begin(9600);
}
void loop() {
etatLed = 1 - etatLed;
digitalWrite(D7, etatLed);
compteur++;
Serial.println(etatLed ? "ON" : "OFF");
delay(1000);
// Particle.process() est appele en arriere-plan en mode AUTOMATIC :
// le lien cloud reste vivant meme avec ce delay.
}