Page 2 of 3

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

Posted: Thu Oct 11, 2018 8:05 pm
by WiFive
Yes using gpio wakeup will affect uart data. So it appears your only option is to use uart0 on default pins and use OTA to flash or just disconnect card reader when flashing.

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

Posted: Fri Oct 12, 2018 7:12 am
by Ritu21
Hi,

I tried using the UART 0 as wake source but no luck. Facing same issues.
Can you write code snippet for using UART 0 as wake source for light sleep mode ??

Regards
Ritu

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

Posted: Fri Oct 12, 2018 7:52 am
by WiFive
Did you use default pin gpio3? Try console example.

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

Posted: Fri Oct 12, 2018 8:29 am
by Ritu21
yes I used GPIO3.

#define TXD_PIN (GPIO_NUM_1)
#define RXD_PIN (GPIO_NUM_3)

uart_set_pin(UART_NUM_0, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); //Uart configuration
void wakeup_uart(void *pvParam)
{
while(1)
{
printf(".. Configuring UART for light sleep mode...\n");
ESP_ERROR_CHECK(uart_set_wakeup_threshold(UART_NUM_0, wake_thresh));
vTaskDelay(2000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(esp_sleep_enable_uart_wakeup(UART_NUM_0));
printf("...SLEEP MODE...\n");
vTaskDelay(5000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(esp_light_sleep_start());
printf("CPU Awake\n");
esp_sleep_disable_wakeup_source(UART_NUM_0);

}
}
See, this is how I wrote code. This is not the complete code but the part of it. Let me know if there is any coding error.

Thx.

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

Posted: Mon Oct 15, 2018 6:09 am
by Ritu21
Hi,

In console example, deep sleep mode is used and that too for timer and GPIO. I really don't understand how do you want me to check with that example for light sleep mode using UART as wake up option.

Please reply on urgent basis.

Thanks
R.

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

Posted: Mon Oct 15, 2018 6:51 am
by WiFive
The example docs are out of date

https://github.com/espressif/esp-idf/bl ... #L293-L295

Also notice how console example uses ref_tick as uart clock

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

Posted: Wed Oct 17, 2018 7:11 am
by Ritu21
Hey,

I am able to use UART 0 as wake up source but the first data on UART gets corrupted. Next all is fine till the time UART is awake.
Please suggest something to avoid this?

Thanks
R.

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

Posted: Wed Oct 17, 2018 9:22 pm
by WiFive

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

Posted: Wed Oct 17, 2018 9:24 pm
by WiFive
https://github.com/espressif/esp-idf/bl ... #L809-L814

You may be able to tune the number of edges threshold to drop a reliable number of bits and make it possible to receive most of the packet assuming you can live without those bits.

Otherwise you may be able to use gpio wakeup and capture and decode the bitstream with RMT.

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

Posted: Thu Oct 18, 2018 11:37 am
by Ritu21
Hey,

This point had clicked me when I saw first data on UART as corrupted. Threshold level needs to be >= 3, whereas Start bit is received when UART communication starts, We can even use 1 as the threshold level in below function but it gives error on boot.

esp_err_t uart_set_wakeup_threshold(uart_port_t uart_num, int wakeup_threshold);

So if you are saying that ESP32 will wake up at threshold level >= 3, then I think that first data after every wake-up from light sleep mode should be discarded.

Suggest if this the way to avoid the situation.

Thanks
R.