My objective is to wake up the esp32 from deep sleep whenever the sensor output voltage drops from 3.3v to 0. I have tested my setup the sensor works properly it outputs 3,3v across the 10k resistor when I move my hand over it and the esp32 wake-ups when I connect GPIO 13 to the ground (esp32 wakes up).
The problem I am facing is that when I connect my sensor output to GPIO 13 things don't make sense, from what I understand the device should only wake up when the sensor changes voltage from 3,3 to GND. This doesn't seem to be the case the esp32 keeps waking up randomly in 1-2 seconds after the deep_sleep start function is called. I thought maybe something is wrong with the sensor so I connected the GPIO 13 straight to GND and that shouldn't trigger the wake interrupt right? But I am seeing the same behaviour. Can anyone help figure out what's wrong?
Code: Untitled.c Select all
#define MOTION_WAKEUP_PIN 13
void gpio_init(gpio_int_type_t INTR_MODE, gpio_mode_t PIN_MODE , gpio_pull_mode_t UP_MODE , gpio_pull_mode_t DOWN_MODE, u_int32_t PIN)
{
gpio_config_t io_config;
io_config.intr_type = INTR_MODE;
io_config.mode = PIN_MODE;
io_config.pull_up_en = UP_MODE;
io_config.pull_down_en = DOWN_MODE;
io_config.pin_bit_mask = 1ULL << PIN;
gpio_config(&io_config);
}
void app_main(void)
{
//Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
ESP_LOGI(wifi_TAG, "ESP_WIFI_MODE_STA");
wifi_init_sta();
gpio_init(GPIO_INTR_NEGEDGE,GPIO_MODE_INPUT,GPIO_PULLUP_ENABLE,GPIO_PULLDOWN_DISABLE,MOTION_WAKEUP_PIN);
while(1){
vTaskDelay(5000 / portTICK_RATE_MS);
esp_deep_sleep_start();
}
}
