Page 1 of 3

UART as wake-up source in Light sleep mode

Posted: Wed Sep 05, 2018 5:47 am
by Ritu21
In technical reference manual of ESP32 ver-3.7 page no- 634-635, it is mentioned that UART can be set as wake-up source "Wake-up is triggered when the number or positive edges of RxD signal is greater than or equal to (UART_ACTIVE_THRESHOLD+2)."

I did this in my code:
REG_WRITE(UART_SLEEP_CONF_REG(UART_NUM_1),UART_ACTIVE_THRESHOLD); // value of threshold = 5
REG_WRITE(RTC_CNTL_WAKEUP_STATE_REG,((uint32_t)(REG_READ(RTC_CNTL_WAKEUP_STATE_REG) | 0x40000)));
esp_light_sleep_start();

ESP32-Wroom-32D is going on light sleep mode but never waking whenever RFID card is shown to the module. Am I missing something here???

Thanks
Ritu

Re: UART as wake-up source in Light sleep mode

Posted: Tue Sep 11, 2018 1:14 pm
by Ritu21
I dont any reply for any of my questions.

Re: UART as wake-up source in Light sleep mode

Posted: Wed Sep 12, 2018 2:34 am
by ESP_igrr
The issue, I think, is that esp_light_sleep_start will overwrite the wakeup selection you have set in the register. Can you please try using the following APIs instead of manual register operations?

https://docs.espressif.com/projects/esp ... rt_port_ti

https://docs.espressif.com/projects/esp ... rt_wakeupi

Re: UART as wake-up source in Light sleep mode

Posted: Fri Oct 05, 2018 12:16 pm
by Ritu21
Hi,
Thanks for the reply.
I wrote a below task on ESP32, module is going in light sleep mode but not waking up when RFID card is shown.

void wakeup_uart(void *pvParam)
{
int wake_thresh = 3;
while(1)
{
printf(".. Configuring UART for light sleep mode...\n");
vTaskDelay(5000 / portTICK_PERIOD_MS);
printf("...CPU Going to sleep...\n");
uart_set_wakeup_threshold(UART_NUM_1, wake_thresh);
uart_get_wakeup_threshold(UART_NUM_1, &wake_thresh);
esp_sleep_enable_uart_wakeup(UART_NUM_1);
vTaskDelay(5000 / portTICK_PERIOD_MS);
esp_light_sleep_start();
printf("...Exiting from light sleep mode...\n");

}
}

Looking for your soonest reply.

Thanks
Ritu

Re: UART as wake-up source in Light sleep mode

Posted: Mon Oct 08, 2018 6:01 am
by Ritu21
Waiting for your reply. Its Urgent...!!!

Re: UART as wake-up source in Light sleep mode

Posted: Wed Oct 10, 2018 7:35 am
by Ritu21
Please reply. :oops:

Re: UART as wake-up source in Light sleep mode

Posted: Wed Oct 10, 2018 2:59 pm
by ESP_igrr
Sorry for the late reply. Could you try EXT0 or EXT1 wake up method for UART RX pin, and see if it can wake the chip up from light sleep when something is received? Another thing to try, connect the external serial device to UART0 instead of UART1, and see if wake up from UART0 works using your code.

Re: UART as wake-up source in Light sleep mode

Posted: Thu Oct 11, 2018 7:35 am
by Ritu21
Hi,

Method1:
So I am using GPIO 5 as Uart Rx. This is how you are saying
esp_sleep_enable_ext0_wakeup(GPIO_NUM_5, 1)
esp_sleep_enable_gpio_wakeup()
If it is ok, GPIO 5 cannot be used as wakeup source since it doesn't have RTC functionality.

Method2:
I cannot use UART0, since I am using it for flash the image.

Hope to see your early response.

Regards
Ritu

Re: UART as wake-up source in Light sleep mode

Posted: Thu Oct 11, 2018 9:48 am
by WiFive
UART1 wakeup does not seem to work on the console example either but gpio wakeup on gpio5 works with uart rx. Uart0 seems only works on default mux pins.

Re: UART as wake-up source in Light sleep mode

Posted: Thu Oct 11, 2018 11:14 am
by Ritu21
I used GPIO 4 for Uart1 Rx but either data get corrupted when input level is low(0) in EXT0 or it is always awake when input level is high (1). Below is my code:

printf(".. Configuring UART for light sleep mode...\n");
rtc_gpio_pulldown_en(RXD_PIN);
ESP_ERROR_CHECK(esp_sleep_enable_ext0_wakeup(RXD_PIN, 1)); //input level is high.
//vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("CPU going on sleep mode\n");
vTaskDelay(2000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(esp_light_sleep_start());
printf("CPU Awake\n");
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0);

RXD_PIN is GPIO_NUM_4.

Where am I wrong???