Code: Select all
#define SLEEPTIMEOUT 3000
int lastActive;
void setup(void)
{
lastActive = millis();
}
void loop()
{
if (millis() - lastActive > SLEEPTIMEOUT)
{
uint64_t ext_wakeup_pin_1_mask = 0;
ext_wakeup_pin_1_mask |= (1ULL << WAKEUPPIN);
esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask, ESP_EXT1_WAKEUP_ANY_HIGH);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
wasAsleep = true;
esp_light_sleep_start();
delay(500);
}
}
Is it possible to set a threshold so that the device only wakes up if the reading on the GPIO pin is above a certain level?
Thanks.