Let's first look at the pin diagram
of the ESP32 development board. Here we use UART 2 as a serial port to communicate with the MCU ( TX : GPIO17, RX : GPIO16). The Arduino code is as follows:
void setup() {
Serial.begin(115200);
Serial2.begin(115200);
}
void loop() {
if (Serial2.available()) {
int inByte = Serial2.read();
Serial.write(inByte);
}
if (Serial.available()) {
int inByte = Serial.read();
Serial2.write(inByte);
}
}