🛠 Sommeil profond et réveil sur broche WKP

Particle Photon · avance · Schéma : IMG-particle-photon-avance-1-photon-sommeil-reveil.svg — Photon sur batterie avec la broche WKP reliée à un interrupteur magnétique et l'RTC de sauvegarde

Objectives

Extend battery autonomy: the Photon consumes approximately 80 mA during active Wi-Fi operation but only ~80 µA in deep sleep (datasheet, Power). You will put the board to sleep between measurements and wake it up via the WKP pin or through a remote cloud command.

Hardware

Complete code

// photon-sommeil-reveil.ino — mesure, sommeil profond, réveil WKP
#include <application.h>

void setup {
  Serial.begin(9600);
  pinMode(D7, OUTPUT);
  digitalWrite(D7, HIGH);
  int brut = analogRead(A0);                 // mesure avant de dormir
  Particle.publish("capteur/brut", String(brut), PRIVATE);
  digitalWrite(D7, LOW);
  Serial.println("Endormissement...");
  // > 
  // Device OS API reference (modes, delai, broche de reveil).
  System.sleep(WKP, RISING, 3600, SLEEP_MODE_DEEP);
  // Au reveil, le Photon redemarre : setup est rejoue.
}

void loop { }

Expected verification

After publishing, the board sleeps (consumption drops to ~80 µA); a state change on WKP (or the expiration of the delay) wakes it up: it restarts, reconnects, and publishes a new value. Remote wake-up is possible: curl https://api.particle.io/v1/devices/<ID>/wakeup -d arg=please -H "Authorization: Bearer $TOKEN" (endpoint confirmed by the datasheet).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials