The KB2040 has a many pins, and most pins have multiple functions. This page is a detailed tour of the board.
PrettyPins PDF on GitHub.
- The KB2040 has a USB C connector on the left end of the board. This connector is used to power and program the board. Use a USB Type C cable to plug the KB2040 into your computer.
Along with the USB C connector, the KB2040 has 6 power related pins.
Along the top edge:
- RAW - This pin is for powering NeoPixels or other 5V devices. By default this pin is after the 500mA fuse and polarity-protection diode. That means you can get max 500ma to 1A from this pin before the fuse will pop. If you want to connect directly to the USB power pin (either for USB host support or because you want 2A) You can solder the jumper on the bottom closed: It lets you bypass the 500mA fuse, for up to 2A from USB ports, and is also for USB hosting.
- G - This is common ground for power and logic.
- RST - This is the reset pin. Tie to ground to manually reset the board.
- 3V - This pin is the regulated output from the onboard regulator. You can draw 500mA whether powered by USB or battery.
Along the bottom edge:
- GND - Same as the G pin on the top edge - common ground for power and logic.
On the back of the board, aligned with the USB C connector, is the USB+ > RAW jumper. Solder this closed to bypass the 500mA fuse, for up to 2A from USB ports, as well as USB hosting. Once soldered closed, you can use the RAW pin for powering NeoPixels or other 5V devices.
Logic Pins
I2C and SPI on RP2040
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.
PWM on RP2040
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 KB2040 is assigned a PWM slice and output. For example, A0 is PWM5 A, which means it is first output of the fifth slice. You can have up to 16 PWM objects on the KB2040. 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 A0, you cannot also put a PWM object on D10, because they are both PWM5 A. The PWM slices and outputs are indicated below
Bottom Edge
Digital Pins
These are the digital I/O pins along the bottom edge. They all have multiple capabilities.
- TX/D0 - The main UART0 TX pin. It is also I2C0 SDA, SPI0 MISO and PWM0 A.
- RX/D1 - The main UART0 RX pin. It is also I2C0 SCL, SPI0 CS and PWM0 B.
- D2 - Digital I/O pin 2. It is also I2C1 SDA, SPI0 SCK and PWM1 A.
- D3 - Digital I/O pin 3. It is also I2C1 SCL, SPI0 MOSI and PWM1 B.
- D4 - Digital I/O pin 4. It is also SPI0 MISO, UART1 TX, I2C0 SDA, and PWM2 A.
- D5 - Digital I/O pin 5. It is also SPI0 CS, UART1 RX, I2C0 SCL, and PWM2 B.
- D6 - Digital I/O pin 6. It is also SPI0 SCK, I2C1 SDA, and PWM3 A.
- D7 - Digital I/O pin 7. It is also SPI0 MOSI, I2C1 SCL, and PWM3 B.
- D8 - Digital I/O pin 8. It is also SPI1 MISO, UART1 TX, I2C0 SDA, and PWM4 A.
- D9 - Digital I/O pin 9. It is also SPI1 CS, UART1 RX, I2C0 SCL, and PWM4 B.
Analog Pins
The RP2040 has four ADCs. These pins are the only pins capable of handling analog, and they can also do digital.
- A3 - This pin is ADC3. It is also SPI1 CS, I2C0 SCL and PWM6 B.
- A2 - This pin is ADC2. It is also SPI1 MISO, I2C0 SDA and PWM6 A.
- A1 - This pin is ADC1. It is also SPI1 MOSI, I2C1 SCL and PWM5 B.
- A0 - This pin is ADC0. It is also SPI1 SCK, I2C1 SDA and PWM5 A.
Digital Pins
These are the digital I/O pins along the top edge. They all have multiple capabilities.
- CLK - The main SPI0 SCK pin. It is also I2C1 SDA and PWM1 A.
- MISO - The main SPI0 MISO pin. It is also UART1 TX, I2C0 SDA and PWM2 A.
- MOSI - The main SPI0 MOSI pin. It is also I2C1 SCL and PWM1 B.
- D10 - Digital I/O pin 10. It is also SPI1 SCK, I2C1 SDA and PWM5 A.
The KB2040 comes with a built in STEMMA QT connector! This means you can connect up all sorts of I2C sensors and breakouts, no soldering required! This connector uses the SCL and SDA pins for I2C. In CircuitPython, you can use the STEMMA connector with board.SCL
and board.SDA
, or board.STEMMA_I2C()
.
- SCL/D13 - This is the main I2C0 SCL pin. It is also SPI1 CS, UART0 RX and PWM6 B.
- SDA/D12 - This is the main I2C0 SDA pin. It is also SPI1 MISO, UART0 TX and PWM6 A.
CircuitPython I2C, SPI and UART
Note that in CircuitPython, there is a board object each for I2C, SPI and UART that use the pins and connector labeled on the KB2040. You can use these objects to initialise these peripherals in your code.
-
board.STEMMA_I2C()
uses I2C STEMMA QT connector (SCL/SDA) -
board.SPI()
uses CLK/MOSI/MISO -
board.UART()
uses RX/TX
GPIO Pins by Pin Functionality
Primary pins based on the KB2040 silk are bold.
I2C Pins
- I2C0 SCL: SCL, RX, D5, D9, A3, MOSI
- I2C0 SDA: SDA, TX, D4, D8, A2, D10
- I2C1 SCL: D3, D7, A1, MOSI
- I2C1 SDA: D2, D6, A0, CLK
SPI Pins
- SPI0 SCK: SCK, D2, D6
- SPI0 MOSI: MO, D3, D7
- SPI0 MISO: MI, TX, D4
- SPI0 CS: RX, D5
- SPI1 SCK: A0, D10
- SPI1 MOSI: A1,
- SPI1 MISO: D8, A2
- SPI1 CS: D9, A3
UART Pins
- UART0 TX: TX,
- UART0 RX: RX
- UART1 TX: D4, D8, MISO
- UART1 RX: D5, D9
PWM Pins
- PWM0 A: TX,
- PWM0 B: RX
- PWM1 A: D2, CLK
- PWM1 B: D3, MOSI
- PWM2 A: D4, MISO
- PWM2 B: D5
- PWM3 A:D6
- PWM3 B: D7
- PWM4 A: D8
- PWM4 B: D9
- PWM5 A: A0, D10
- PWM5 B: A1
- PWM6 A: A2
- PWM6 B: A3
The square towards the middle is the RP2040 microcontroller, the "brains" of the KB2040 board.
The square between the RP2040 and the USB connector is the QSPI Flash. It is connected to 6 pins that are not brought out on the GPIO pads. This way you don't have to worry about the SPI flash colliding with other devices on the main SPI connection.
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.
The KB2040 has two buttons.
- The RST button (reset) restarts the board and helps enter the bootloader. You can click it to reset the board without unplugging the USB cable or battery.
- The BOOT (boot select) button is used to enter the bootloader. To enter the bootloader, press and hold BOOT and then power up the board (either by plugging it into USB or pressing RST). The bootloader is used to install/update CircuitPython. This button is also usable as an input in CircuitPython code, on pin
board.BUTTON
.
- The RGB NeoPixel LED is located near CLK on the silk. It is controllable in CircuitPython code using the pin
board.NEOPIXEL
. - Above the USB C connector is the green power LED.
On either side of the USB C connector, on the USB-end of the board, are the D+ and D- pins for alternative USB connections.
Page last edited March 31, 2024
Text editor powered by tinymce.