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

28 lines
651 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);
// Włącz LED aktywny stan
digitalWrite(LED_PIN, HIGH);
Serial.println("ESP32 aktywne LED ON");
delay(5000); // 2 sekundy "pracy"
// Wyłącz LED przed snem
digitalWrite(LED_PIN, LOW);
Serial.println("Przechodzę w deep sleep na 5 sekund...");
// Konfiguracja wybudzenia po 5 sekundach
esp_sleep_enable_timer_wakeup(5 * 1000000ULL);
// Wejście w deep sleep (ESP restartuje się po wybudzeniu)
esp_deep_sleep_start();
}
void loop() {
// Tu nic się nie dzieje kod nigdy tu nie wraca w deep sleep
}