Which pins can you use for UART on the ESP32?

One the ESP32 can use any pin for UART. While using certain special pins has extremely small performance benefits, those don’t really matter in practice.

// Use GPIO2 and GPIO4 for Serial2
Serial2.begin(115200, SERIAL_8N1,
              2 /* RX pin */,
              4 /* TX pin */);