This is a top view of the pinouts on the Raspberry Pi Pico. The pin labels are on the bottom of the board. See the Downloads page for a paper template you can put underneath the Pico to label the pins.

There are two I2C peripherals available, I2C0 and I2C1, two SPI peripherals, SPI0 and SPI1, and two UART peripherals, UART0 and UART1. You can assign any of these to the pins on which they are available. So for example, you can use GP0/GP1 for I2C0, and simultaneously use GP2/GP3 for I2C1, but you cannot use GP0/GP1 together with GP4/GP5 for I2C use, because they are both usable only with I2C0.

In CircuitPython, you don't need to specify exactly which peripheral is used. As long you choose valid pins, CircuitPython will choose a free peripheral.

No Default board Devices

The Pico does not label specific pins as the defaults to use for I2C, SPI, or UART connections. So CircuitPython running on the Pico does not provide board.I2C(), board.SPI(), or board.UART(), since it's not immediately obvious what they would correspond to. For example:

import board

i2c = board.I2C()    # Does not work on the Pico.

Instead, use the busio module to create your bus and then specify the specific pins you want to use. To do so, use the pinout diagram above to find available pins, for example I2C0_SDA is on GP0 (as well as other locations). You then use the board.GPx pin name when creating the bus.

Here are some specific examples.

I2C Example

To setup an I2C bus, you specify the SCL and SDA pins being used. You can look for "SCL" and "SDA" in the pin names in the pinout diagram above.

  • I2Cx_SCL = SCL
  • I2Cx_SDA = SDA

For example, here is how you would setup an I2C bus to use GP1 as SCL and GP0 as SDA:

import board
import busio

i2c = busio.I2C(scl=board.GP1, sda=board.GP0)

SPI Example

To setup a SPI bus, you specify the SCK, MOSI (microcontroller out, sensor in), and MISO (microcontroller in, sensor out) pins. The Pico uses a different naming convention for these:

  • SPIx_SCK = SCK
  • SPIx_TX = MOSI
  • SPIx_RX = MISO

So use that mapping to help find available pins.

Here's an example:

import board
import busio

spi = busio.SPI(clock=board.GP2, MOSI=board.GP3, MISO=board.GP4)

UART Example

To setup a UART bus, you specify the TX and RX pins. Be sure to use the UARTx pins and not the similarly named SPIx ones.

Here's an example:

import board
import busio

uart = busio.UART(tx=board.GP4, rx=board.GP5)

This guide was first published on Jan 21, 2021. It was last updated on 2021-03-03 12:34:49 -0500.

This page (Pinouts) was last updated on Oct 23, 2021.

Text editor powered by tinymce.