7

I want to wake up the ESP when it receives a message on the UART2 port. However, with the following code it never wakes up, even if a message is received. I am using the Lolin 32 Lite Devboard.

#include <Arduino.h>
#include <driver/uart.h>
#include <esp_sleep.h>

void setup() {
    Serial.begin(9600);

    Serial2.begin(115200, SERIAL_8N1);

    uart_set_wakeup_threshold(UART_NUM_2, 3);
    esp_sleep_enable_uart_wakeup(UART_NUM_2);
}

void loop() {
    Serial.println("loop");
    delay(500);
    while (Serial2.available()) {
        Serial.println(Serial2.readStringUntil('\n'));
    }

    esp_light_sleep_start();
}

1 Answer 1

4

I want to wake up the ESP when it receives a message on the UART2 port.

Unfortunately only UART0 and UART1(if available in the ESP32 you are using) can be used as the light sleep wake up source. UART_NUM_2 (Serial2) does not work as a wake source. This is not quite well documented except it is only briefly mentioned in the ESP-IDF documentation. See Note #2:

Note #2: only UART0 and UART1 (if has) are supported to be configured as wake up source. And for ESP32, we have to use iomux pin for RX signal (i.e. GPIO3 for UART0 & GPIO9 for UART1), otherwise it won't success.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.