Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To receive UART traffic on an Arduino ESP32, you can use the built-in Serial library.

Here's an example code:

void setup() {
  Serial.begin(9600); // Set baud rate to 9600
}

void loop() {
  if (Serial.available()) { // If there is data available
    char incomingByte = Serial.read(); // Read the incoming byte
    Serial.print("Received: "); 
    Serial.println(incomingByte); // Print the incoming byte to the serial monitor
  }
}

In this example, we first set up the serial communication with a baud rate of 9600 using the Serial.begin() function in the setup() function.

In the loop() function, we check if there is any incoming data using the Serial.available() function. If there is data available, we read the incoming byte using the Serial.read() function and then print it to the serial monitor using the Serial.println() function.

You can use this basic code as a starting point for your own application and modify as needed to process the incoming data.