deepsleep-minute.ino

Arduino Nano ESP32 · File : deepsleep-minute.ino · Language : Arduino · Use case : Réveil toutes les minutes en deep sleep

ESP32-S3 deep sleep drops to about ten microamps: only the RTC timer alive, wake-up after 60 seconds with the program reset. RTC_DATA_ATTR preserves the cycle counter in slow memory, the pattern of ESP32 battery sensors.

Hardware

An Arduino Nano ESP32 (dual-core ESP32-S3, 2.4 GHz Wi-Fi + Bluetooth Low Energy, Nano-compatible physical pinout, native USB, 3.3 V pins only). Nano ESP32 on USB to develop; in production a sober LDO regulator (the module idles above the SoC silence).

Wiring

No wiring; mind U0TXD/SENSOR_0 pins if you add an external GPIO wake-up.

How it works

esp_sleep_enable_timer_wakeup programs the 60 s timer in microseconds; esp_deep_sleep_start cuts everything and restarts at the bootloader. RTC_DATA_ATTR places the variable in RTC slow memory, spared by power-down.

Running it

Install the Arduino ESP32 Boards package (or follow the official Nano ESP32 guide), select Arduino Nano ESP32, upload. Pins are 3.3 V: never feed 5 V into an input. The serial monitor uses native USB.

Variants

Also wake on a sensor (esp_sleep_enable_ext0_wakeup), or combine with WiFi for a measure+send cycle of a few hundred ms.

deepsleep-minute.ino

// Deep sleep ESP32-S3 : tout est coupe sauf le minuteur RTC (~10 uA).
// La RAM est perdue : on sauve l'etat dans la NVS ou en RTC slow mem.
#include <Preferences.h>

Preferences prefs;
RTC_DATA_ATTR uint32_t cycles = 0; // survit au deep sleep (RTC slow)

void setup() {
  Serial.begin(115200);
  delay(100); // laisser le pont USB s'ouvrir (evite le blocage)
  cycles++;
  Serial.print(F("Reveil n°"));
  Serial.println(cycles);

  // ... mesure + envoi ici (WiFi/BLE au reveil) ...

  Serial.println(F("Endormi 60 s..."));
  Serial.flush();
  delay(10);
  esp_sleep_enable_timer_wakeup(60ULL * 1000000ULL); // 60 s en us
  esp_deep_sleep_start(); // ne revient jamais ici
}

void loop() {} // jamais atteint : tout se passe dans setup

← Back to the board