-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeep_sleep.h
More file actions
35 lines (30 loc) · 823 Bytes
/
deep_sleep.h
File metadata and controls
35 lines (30 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
////////////////////////
// Sleep Controls
void print_wakeup_reason(){
//ESP_RST_UNKNOWN
//ESP_RST_POWERON
//ESP_RST_EXT
//ESP_RST_SW
//ESP_RST_PANIC
//ESP_RST_INT_WDT
//ESP_RST_TASK_WDT
//ESP_RST_WDT
//ESP_RST_DEEPSLEEP
//ESP_RST_BROWNOUT
//ESP_RST_SDIO
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
}
}
void enter_deep_sleep(int sleep_seconds = 0) {
if (sleep_seconds == 0) {
sleep_seconds = TIME_TO_SLEEP;
}
Serial.println("Entering sleep for " + String(sleep_seconds) + " Seconds");
Serial.flush();
esp_deep_sleep_start();
}