You need to use Serial1
object to map with GPIO pins. Any of pins (A, B, C, D) are available.
There is also Serial2
, but it can’t be used.
void setup() {
// Begin UART over GPIO pins (config: 8bit data, 1 stop bit, no parity)
Serial1.begin(115200, SERIAL_8N1, GPIOA, GPIOB); // baud, config, rx, tx
}
int counter;
void loop() {
// Use "Serial1" to print over GPIO pins
Serial1.print("Test ");
Serial1.println(counter++);
delay(100);
}
Use standard Serial API to send and receive over UART. Using Serial1
will print to GPIO pins. Serial
will print to Serial Monitor (over USB).
You can also remap Serial
to GPIO pins if 2 UART streams are required.
Keep in mind, that this is only available in board v1.1. Older one’s (v1.0) GPIO pins aren’t connected to ESP32 directly.
Currently working on X4 improvements, so will add more information about it