ESP32 Serial2: pins for a GPS or sensor on a second UART

On many ESP32 boards Serial2 uses GPIO 16 for RX and GPIO 17 for TX by default, and you can set other pins in begin().

What the message means

The ESP32 has three hardware UARTs. UART0 is the USB console, so use Serial2 for a GPS, a sensor or another board.

Fix it in this order

  1. Call Serial2.begin(baud, SERIAL_8N1, rxPin, txPin) with the pins you wired.
  2. Cross the lines: the device TX goes to your RX pin, and its RX goes to your TX pin.
  3. Join the grounds, and use 3.3 V levels. Level-shift a 5 V device TX line.
  4. Match the baud rate to the device datasheet.
  5. Do not use GPIO 6 to 11 or the strapping pins for this.
  6. Print what you receive on the USB Serial to check.

If you see this, do this

You seeDo this
Nothing arrivesTX and RX not crossed, or baud mismatch.
Garbage charactersBaud rate.

serial garbage, ESP32 pinout.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.