Thanks for giving the description of the problem. Yes, this was an issue in the master branch a few commits ago; I remember giving this workaround in one of the github issues. This does not solve any hardware bug (would have been nice though), it was software issue, which should be fixed now in the latest master.spurious watchdog resets ... which used to happen after second wakeup
DEEPSLEEP_RESET
Re: DEEPSLEEP_RESET
Re: DEEPSLEEP_RESET
For my part, problem is now solved. I just had to change these 2 lines of code from
... to
Thanks for your help.
Code: Select all
gpio_pullup_en(GPIO_INPUT_IO_TRIGGER); // use pullup on GPIO
gpio_pulldown_dis(GPIO_INPUT_IO_TRIGGER); // not use pulldown on GPIO
Code: Select all
gpio_pullup_dis(GPIO_INPUT_IO_TRIGGER); // not use pullup on GPIO
gpio_pulldown_en(GPIO_INPUT_IO_TRIGGER); // use pulldown on GPIO
Re: DEEPSLEEP_RESET
Ok so I thought that this line of code
... would ensure that ESP32 only woke up if GPIO_NUM_13 had a logic level of 1 but it wakes up regardless of level the wire I attach to GPIO_NUM_13 is floating or has 3.3 volt.
Is there something extra I need to do
In case you need it, the entire sourcecode is now
Thanks
Code: Select all
esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_13, 1); // Wake if GPIO is high
Is there something extra I need to do
In case you need it, the entire sourcecode is now
Code: Select all
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sdkconfig.h"
#include "esp_deep_sleep.h"
/*
* Only GPIOs which are have RTC
* functionality can be used: 0,2,4,12-15,25-27,32-39.
*
* I Use GPIO 13
*/
void app_main() {
gpio_set_direction(GPIO_NUM_13, GPIO_MODE_INPUT);
printf("esp_deep_sleep_get_wakeup_cause\n");
switch (esp_deep_sleep_get_wakeup_cause()) {
case ESP_DEEP_SLEEP_WAKEUP_UNDEFINED: {
printf("Wakeup was not caused by deep sleep\n");
break;
}
case ESP_DEEP_SLEEP_WAKEUP_EXT0: {
printf("Wakeup caused by external signal using RTC_IO\n");
break;
}
case ESP_DEEP_SLEEP_WAKEUP_EXT1: {
printf("Wakeup caused by external signal using RTC_CNTL\n");
break;
}
case ESP_DEEP_SLEEP_WAKEUP_TIMER: {
printf("Wakeup caused by timer\n");
break;
}
case ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD: {
printf("Wakeup caused by touchpad\n");
break;
}
case ESP_DEEP_SLEEP_WAKEUP_ULP: {
printf("ESP_DEEP_SLEEP_WAKEUP_ULP\n");
break;
}
}
printf("start ESP32\n");
printf("The logic level of gpio %d is %d\n", GPIO_NUM_13, gpio_get_level(GPIO_NUM_13));
printf("config IO\n");
esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_AUTO); //!< Keep power domain enabled in deep sleep, if it is needed by one of the wakeup options. Otherwise power it down.
gpio_set_pull_mode(GPIO_NUM_13, GPIO_PULLDOWN_ONLY);
// gpio_pullup_dis(GPIO_NUM_13); // not use pullup on GPIO
// gpio_pulldown_en(GPIO_NUM_13); // use pulldown on GPIO
esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_13, 1); // Wake if GPIO is high
printf("deep sleep\n");
esp_deep_sleep_start();
}
-
- Posts: 9833
- Joined: Thu Nov 26, 2015 4:08 am
Re: DEEPSLEEP_RESET
That is because gpio_set_pull_mode sets the pull-ups and -downsa in the digital domain, which gets powered down when the CPU enters deep sleep(untrue, see edit), leaving your pin floating. If you do not pull it up or down externally, it'll just be flapping in the breeze, picking up charge from whatever stray EMF it comes across. Chances are pretty large that makes the pin positive for long enough to get it out of deep sleep at any given point in time.
Edit: Seems gpio_sets_pull_mode does enable pullups/downs in the RTC domain when used on RTC pins. Something else possibly is making these pullup/downs not work.
Edit: Seems gpio_sets_pull_mode does enable pullups/downs in the RTC domain when used on RTC pins. Something else possibly is making these pullup/downs not work.
Re: DEEPSLEEP_RESET
Doesnt keeping rtc peripheral domain powered up include pullup/down?ESP_Sprite wrote:That is because gpio_set_pull_mode sets the pull-ups and -downsa in the digital domain, which gets powered down when the CPU enters deep sleep, leaving your pin floating. If you do not pull it up or down externally, it'll just be flapping in the breeze, picking up charge from whatever stray EMF it comes across. Chances are pretty large that makes the pin positive for long enough to get it out of deep sleep at any given point in time.
https://github.com/espressif/esp-idf/bl ... pio.c#L110
https://github.com/espressif/esp-idf/bl ... leep.c#L41
https://github.com/espressif/esp-idf/bl ... leep.c#L61
-
- Posts: 9833
- Joined: Thu Nov 26, 2015 4:08 am
Re: DEEPSLEEP_RESET
Yes, seemingly I derped and didn't remember the pullup/down enable call uses the RTC domain on RTC GPIOs. Will edit my post, I think there's something else keeping the pullup/downs from working correctly.
Re: DEEPSLEEP_RESET
This code snippet does enable the pulldown correctly. You can actually verify this by connecting an ammeter between GPIO13 and VCC. With gpio_set_pull_mode function called, the current flowing into the pin will be around 76 uA, which is equivalent to ~43k of pullup resistance. Without gpio_set_pull_mode function called, the current will be less than a microamp.
43k is not a very strong pullup, and depending on the wire length and EM fields around, it may not be enough to keep the input at low level. In my case, wakeup doesn't happen when there is a 10cm wire attached to the pin, but if I touch the wire end with a finger, that is enough to cause wakeup.
43k is not a very strong pullup, and depending on the wire length and EM fields around, it may not be enough to keep the input at low level. In my case, wakeup doesn't happen when there is a 10cm wire attached to the pin, but if I touch the wire end with a finger, that is enough to cause wakeup.
Re: DEEPSLEEP_RESET
Thanks for your interest.
I'm not sure what to conclude from your findings and to achieve the ESP32 to wake up when logic level of GPIO13 is high and not in other cases?
Thanks you again.
I'm not sure what to conclude from your findings and to achieve the ESP32 to wake up when logic level of GPIO13 is high and not in other cases?
Thanks you again.
Re: DEEPSLEEP_RESET
The conclusion is that you need to provide a definite logic level at the IO used for wakeup. As explained above, a dangling wire connected to an IO may pick up EMI which may be enough to momentarily produce high logic level on the input. Internal pullup/pulldown resistors may not be strong enough for all use cases.
If you see wakeup happening when it is not supposed to, connect an external pullup/pulldown resistor to the IO. Another option is to add a small capacitor between an IO and ground to filter out induced high-frequency signal. As a rule of thumb, C = t/Rpd, where t is the shortest pulse width you want to be filtered out, and Rpd is the pulldown resistance (internal or external).
If you see wakeup happening when it is not supposed to, connect an external pullup/pulldown resistor to the IO. Another option is to add a small capacitor between an IO and ground to filter out induced high-frequency signal. As a rule of thumb, C = t/Rpd, where t is the shortest pulse width you want to be filtered out, and Rpd is the pulldown resistance (internal or external).
Re: DEEPSLEEP_RESET
Ok, I now understand.
What I do not understand is, if I connect the wire to GND I would expect the GPIO to be brought down when connecting with the wire. But even so I trigger the wake up.
Thanks
What I do not understand is, if I connect the wire to GND I would expect the GPIO to be brought down when connecting with the wire. But even so I trigger the wake up.
Thanks
Who is online
Users browsing this forum: No registered users and 114 guests