Put esp32 to sleep
This commit is contained in:
parent
fb30109f42
commit
0ba0101ff6
@ -6,10 +6,13 @@
|
||||
#include "network.h"
|
||||
|
||||
void fetchAndDrawImage();
|
||||
void hibernate_and_restart();
|
||||
|
||||
const char *ssid = WIFI_SSID;
|
||||
const char *password = WIFI_PASSWORD;
|
||||
|
||||
#define HIBERNATE_TIME_SEC 120 // hibernate time in seconds
|
||||
|
||||
const char *serverName = "http://192.168.3.133:8080/fetchImage";
|
||||
|
||||
void setup()
|
||||
@ -60,6 +63,21 @@ void fetchAndDrawImage() {
|
||||
}
|
||||
|
||||
http.end();
|
||||
|
||||
hibernate_and_restart();
|
||||
}
|
||||
|
||||
void hibernate_and_restart() {
|
||||
// Go to sleep and wake up later
|
||||
|
||||
// Configure wake up source as timer
|
||||
esp_sleep_enable_timer_wakeup(HIBERNATE_TIME_SEC * 1000000);
|
||||
|
||||
// Enter hibernation mode
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user