The QT Py RP2040 packs all kinds of microcontroller goodness into a super tiny package. Time to take a tour of the board!
On the opposite end of the board from the USB connector is the STEMMA QT connector. This connector, labeled I2C1, allows you to plug in all sorts of breakout boards with no soldering needed! All you need is a STEMMA QT cable.
NOTE: To use this connector with CircuitPython, you need to use
- USB C connector - This is used for power and data. Connect to your computer via a USB C cable to update firmware and edit code.
- GND - This is the common ground for all power and logic.
- 3V - this is the regulated output from the onboard regulator. You can draw 500mA
- 5V - This is 5v out from the USB port. You can also use this as a voltage input but you must have some sort of diode (schottky, signal, power, really anything) between your external power source and this pin with anode to battery, cathode to 5V pin. Note that you cannot power the USB port by supplying 5V to this pin: there is a protection diode that prevents the 5V from reaching the USB connector (unless you bridge the jumper on the back!). This is to protect host computer USB ports, etc. You can draw 1A peak through the diode, but we recommend keeping it lower than that, about 500mA
The RP2040 is capable of handling I2C, SPI and UART on many pins. However, there are really only two peripherals each of I2C, SPI and UART: I2C0 and I2C1, SPI0 and SPI1, and UART0 and UART1. So while many pins are capable of I2C, SPI and UART, you can only do two at a time, and only on separate peripherals, 0 and 1. I2C, SPI and UART peripherals are included and numbered below.
The RP2040 supports PWM on all pins. However, it is not capable of PWM on all pins at the same time. There are 8 PWM "slices", each with two outputs, A and B. Each pin on the QT Py is assigned a PWM slice and output. For example, D6 is PWM2 A, which means it is the first output of the second slice. You can have multiple PWM objects on the QT Py RP2040. The important thing to know is that you cannot use the same slice and output more than once at the same time. So, if you have a PWM object on pin D6, you cannot also put a PWM object on D9, because they are both PWM2 A. The PWM slices and outputs are indicated below.
The RP2040 has four ADCs. These pins are the only pins capable of handling analog, and they can also do digital.
- A0/D0 - This pin is ADC3. It is also SPI1 CS, I2C0 SCL and PWM6 B.
- A1/D1 - This pin is ADC2. It is also SPI1 MISO, I2C1 SDA and PWM6 A.
- A2/D2 - This pin is ADC1. It is also SPI1 MOSI, I2C1 SCL and PWM5 B.
- A3/D3 - This pin is ADC0. It is also SPI1 SCK, I2C1 SDA and PWM5 A.
These are the digital I/O pins. They all have multiple capabilities.
- SDA/D4 - I2C0 SDA, and digital I/O pin 4. It is also UART1 TX and PWM4 A.
- SCL/D5 - I2C0 SCL, and digital I/O pin 5. It is also UART1 RX and PWM4 B.
- TX/D6 - The main UART1 TX pin. It is also I2C0 SDA and PWM2 A.
- RX/D7 - The main UART1 RX pin. It is also SPI0 CS, I2C0 SCL and PWM2 B.
- SCK/D8 - The main SPI0 SCK and digital I/O pin 8. It is also I2C1 SDA and PWM3 A.
- MI/D9 - The main SPI0 MISO and digital I/O pin 9. It is also UART1 TX, I2C0 SDA and PWM2 A.
- MO/D10 - The main SPI0 MOSI and digital I/O pin 10. It is also I2C1 SCL and PWM1 B.
- SDA1 - I2C1 SDA for the STEMMA QT connector. It is also SPI0 SCK and PWM3 A.
- SCL1 - I2C1 SCL for the STEMMA QT connector. It is also SPI0 MOSI and PWM3 B.
CircuitPython I2C, SPI and UART
Note that in CircuitPython, there is a board object each for I2C, SPI and UART that use the pins labeled on the QT Py. You can use these objects to initialise these peripherals in your code.
board.I2C()uses SCL/SDA (not for the STEMMA QT connector!)
Primary pins based on QT Py RP2040 silk are bold.
- I2C0 SCL: SCL, A0, RX
- I2C0 SDA: SDA, TX, MISO
- I2C1 SCL: SCL1, A2, MOSI
- I2C1 SDA: SDA1, A1, A3, SCK
- SPI0 SCK: SCK, SDA1
- SPI0 MOSI: MO, SCL1
- SPI0 MISO: MI
- SPI0 CS: RX
- SPI1 SCK: A3
- SPI1 MOSI: A2
- SPI1 MISO: A1
- SPI1 CS: A0
- UART0 TX: (none)
- UART0 RX: (none)
- UART1 TX: TX, SDA, MISO
- UART1 RX: RX, SCL
- PWM0 A: (none)
- PWM0 B: (none)
- PWM1 A: (none)
- PWM1 B: MOSI
- PWM2 A: TX, MISO
- PWM2 B: RX
- PWM3 A: SCK, SDA1
- PWM3 B: SCL1
- PWM4 A: SDA
- PWM4 B: SCL
- PWM5 A: A3
- PWM5 B: A2
- PWM6 A: A1
- PWM6 B: A0
The onboard NeoPixel is a built-in addressable RGB LED. It can be accessed in CircuitPython with pin
QSPI is neat because it allows you to have 4 data in/out lines instead of just SPI's single line in and single line out. This means that QSPI is at least 4 times faster. But in reality is at least 10x faster because you can clock the QSPI peripheral much faster than a plain SPI peripheral.
There is a jumper on the back next to the QSPI flash chip. If you bridge this jumper, it will connect the USB 5V pin to the breakout 5V pin. This is necessary if you want to use the QT Py RP2040 in USB host mode.