Is it possible to set the threshold for external wake up?
Posted: Fri Feb 08, 2019 7:19 pm
I'm having a chip that sleeps after a few seconds of inactivity and can be woken up by a GPIO that is connected to microphone. The relevant code is here. The wakeup is set to trigger on the GPIO being high.
The problem is, this causes a lot of "false positives" wakeups to appear. The device for example keeps waking up constantly when in a room with lots of people talking or when put in one's pocket. The desired behaviour is that the waking up takes place only if the noise is high enough (the GPIO reading is high enough).
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.
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.