Change Pi Pico Serial Pins

I am working with a respberry Pi Pico board.

What I want to do is to change the pins of the UART0 channel. According to the picture in there should be plenty of alternative pins for the UARTs.

Specifically, I want to put the UART0 channel to GP16 and GP17.
My understanding is, that the definition of UART0 is already hardcoded into the arduino framework.

Is there a way to change the pins of the UART without creating a completely new variant?

Sounds similiar to Change Pi Pico Serial and I2C Pins and use both I2C Ports

Yes, but that trick doesn’t work with Serial1. I get a linker error, because there are two Serial1 Objects.

Sadly there are no #ifndef PIN_SERIAL_TX… checks in

so the best one can do without source code modifications and duplicating the variant is to create Serial2 with the desired pins and use this throughout the firmware instead of Serial1.

For most platforms, it is easy to redirect the variant folder where you could have a duplicate of the variant with only the minimal needed changes (as e.g. here), but sadly in the Pico + Arduino (mbed core) case that is hardcoded here. So I don’t see a nice option to do this besides duplicating the RASPBERRY_PI_PICO in <home folder>/.platformio/packages/framework-arduino-mbed/variants as some other name and setting board_build.variant = <new board variant folder> in the platformio.ini

1 Like

I was afraid of that.
Probably the best way to continue is to give this other core a try:

According to the documentation, they have functions to change the pin assignments.

OK, I have it working now! :partying_face:

I changed my platfomio.ini to this:

;platform = raspberrypi
platform =
board = pico
framework = arduino
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m

platform_packages =

And the demo code in main.cpp looks like this:

#include <Arduino.h>

void setup() {


void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                            // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                            // wait for a second
  Serial1.println("Hello World!");