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.

Why it happens

The ESP32 has three hardware serial ports, and the USB connection uses one of them for the monitor. Serial2 is a separate port whose pins can be remapped in begin(). A UART is a pair of data lines, so the TX of one device must meet the RX of the other, and the grounds must be shared. Without a shared ground, the signal levels have no common reference.

The ESP32 GPIO pins are 3.3 V logic. A device with a 5 V TX output can exceed the input limit and damage the pin, so a level shifter or divider is needed. The baud rate must match the device, and bytes are read correctly only when framing matches too. Printing the raw bytes to the USB monitor shows quickly whether the wiring and speed are right.

If you see this, do this

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

Confirm the fix

  1. Call Serial2.begin with the pins you wired, then print every byte received from the device to Serial.
  2. Use a multimeter in continuity mode to confirm the device TX pin reaches the ESP32 RX pin you configured in begin().
  3. Measure the device TX high level with a multimeter, and if it is above 3.3 V, add a level shifter before the pin.

Common mistake: Assuming Serial2 always uses pins 16 and 17. Those are common defaults on many boards, but the wiring must match the pins passed to begin(), so a mismatch gives silence.

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.