#include <WiFi.h>
//Arduino Uno LED BuiltIn 13
//ESP32 LED BuiltIn >> GPIO2
//ESP32C3 LED BuiltIn >> GPIO8
#define LED_BUILTIN 2
#define SLEEP_MINUTES 1
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
Serial.println("Wake up!");
Serial.println(F("LED_BUILTIN, HIGH"));
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second
Serial.println(F("LED_BUILTIN, LOW"));
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(5000);
// Serial.println(F("Going to sleep..."));
Serial.print(F("Entering Deep Sleep for "));
Serial.print(SLEEP_MINUTES);
Serial.println(F(" minutes..."));
// Sleep อาร์กิวเมนต์ที่ส่งไปมีหน่วยเป็นไมโครวินาที (microSec)
// หมายความว่าค่าตัวเลขที่ส่งไปนั้นคือเวลาในหน่วยไมโครวินาที. 1 ไมโครวินาที
// เท่ากับ \(10^{-6}\) วินาที หรือ 1 ใน 1,000,000 ของวินาที.
esp_sleep_enable_timer_wakeup(SLEEP_MINUTES * 60ULL * 1000000ULL);
esp_deep_sleep_start();
}