UART as wake-up source in Light sleep mode
Re: UART as wake-up source in Light sleep mode
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
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
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
Did you use default pin gpio3? Try console example.
Re: UART as wake-up source in Light sleep mode
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.
#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
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.
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
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
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
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.
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
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.
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
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.
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: Majestic-12 [Bot] and 104 guests