amc2022:grouph:here
This is an old revision of the document!
Table of Contents
Build
Code
#define uS_TO_S_FACTOR 1000000 #define TIME_TO_SLEEP 10 RTC_DATA_ATTR int bootCount = 0; void print_wakeup_reason(){ esp_sleep_wakeup_cause_t wakeup_reason; wakeup_reason = esp_sleep_get_wakeup_cause(); switch(wakeup_reason) { case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("PUSHED BUTTON caused the system to WAKEUP"); break; case ESP_SLEEP_WAKEUP_TIMER : Serial.println("TIMER caused the system to WAKEUP"); break; default : Serial.printf("DeepSleep didn't wake up ESP32: %d\n",wakeup_reason); break; } } void setup(){ Serial.begin(115200); delay(1000); pinMode(32,OUTPUT); pinMode(33,INPUT_PULLUP); for(int i=0;i<5;i++) { digitalWrite(32,HIGH); delay(1000); digitalWrite(32,LOW); delay(1000); } ++bootCount; Serial.println("Reboot count number: " + String(bootCount)); print_wakeup_reason(); esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,0); esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); Serial.println("ESP32 is going into DeepSleep for " + String(TIME_TO_SLEEP) + " Seconds"); Serial.println("Going to sleep now......"); delay(1000); Serial.flush(); esp_deep_sleep_start();
Description
Results
amc2022/grouph/here.1661461777.txt.gz · Last modified: 2023/01/05 14:38 (external edit)