Files
Arduino/ESP32/Sleep/LightSleep/LightSleep.ino
2025-09-11 19:48:15 +02:00

30 lines
704 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <esp_sleep.h>
#define LED_PIN 2
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
}
void loop() {
// LED ON (czas aktywny)
digitalWrite(LED_PIN, HIGH);
Serial.println("ESP32 aktywne LED ON");
delay(5000); // symulacja pracy przez 2 sekundy
// Przygotowanie do light sleep
Serial.println("Przechodzę w light sleep na 5 sekund...");
digitalWrite(LED_PIN, LOW); // LED OFF w czasie uśpienia
delay(100);
// Konfiguracja wybudzenia po czasie
esp_sleep_enable_timer_wakeup(5 * 1000000ULL); // 5s w mikrosekundach
// Wejście w light sleep
esp_light_sleep_start();
// Po wybudzeniu wracamy tutaj
Serial.println("Wybudzono z light sleep!");
}