UART as wake-up source in Light sleep mode

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Thu Oct 11, 2018 8:05 pm

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.

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

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

Postby Ritu21 » Fri Oct 12, 2018 7:12 am

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

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Fri Oct 12, 2018 7:52 am

Did you use default pin gpio3? Try console example.

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

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

Postby Ritu21 » Fri Oct 12, 2018 8:29 am

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.

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

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

Postby Ritu21 » Mon Oct 15, 2018 6:09 am

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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Mon Oct 15, 2018 6:51 am

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

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

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

Postby Ritu21 » Wed Oct 17, 2018 7:11 am

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.


WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Wed Oct 17, 2018 9:24 pm

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.

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

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

Postby Ritu21 » Thu Oct 18, 2018 11:37 am

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.

Who is online

Users browsing this forum: Baidu [Spider], chegewara, dssman, Majestic-12 [Bot] and 84 guests