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();
}