Adafruit’s latest RP2040 based board is a departure from form factors such as its Feather RP2040, ItsyBitsy and QTPy. The $9 KB2040 is designed to mimic the form factor and pin layout of Arduino’s Pro Micro microcontroller boards. But why? The Arduino Pro Micro is often used to create custom user interface devices, keyboards. KB2040 aims to bring CircuitPython into this popular maker project, and open up a world of possibilities via its Stemma QT connector.
The $9 price tag is more than double the cost of a Raspberry Pi Pico, so what do we get for our extra cash, and what can we do with it? We put Adafruit’s KB2040 on the bench and took it for a test drive, including using it to control OBS during our live streamed The Pi Cast show.
Adafruit KB2040 Specifications
|SoC||RP2040 32-bit Cortex M0+ dual core running at 125 MHz @ 3.3V logic and power. 264 KB RAM|
|Storage||8MB SPI Flash|
|GPIO||18 GPIO pins / castellations consisting of|
|4 x 12 bit Analog pins|
|2 x I2C|
|2 x SPI|
|2 x UART|
|16 x PWM|
|10 x Digital IO (PIO compatible)|
|1 x Stemma QT / Qwiic connector|
|Power||5V via USB C|
|RAW output with 500mA fused output, user bypassable.|
|3.3V regulator with 500mA peak current output|
|Features||1 x NeoPixel|
|Bootloader / User programmable button|
|Dimensions||1.4 x 0.7 x 0.2 inches (35 x 17.8 x 4.9mm)|
Using Adafruit KB2040
KB2040, as its name suggests, is designed to enable you to make your own custom keyboard. Whether you prefer Cherry MX Red, Blue, Kailh or Gateron switches, that choice is left to the maker, but to the KB2040 it does not matter.
With 20 GPIO pins (including Stemma QT) on offer, you can create up to 100 key matrices, enough for most keyboard warriors. The selection of GPIO pins is considered, just enough for a keyboard, and more than enough should you wish to press the $9 board into service for other maker projects. The 18 GPIO pins which surround the board are broken out in two ways. The traditional through-hole is ready for header pins, and castellations which enabled KB2040 to be surface mount soldered onto a circuit board, the latter being desirable for those wishing to integrate KB2040 into a slim build.
If you need to tap into the 5V supplied by USB, you can do so using the RAW pin. This pin has a 500mA fuse to reduce the risk of damaging the USB ports. Should you need to draw more current, then on the underside of the board is a jumper which can be soldered closed to allow upto 2A of current draw useful for NeoPixels.
Lastly we have two extra USB breakout pins, D+ and D-. These two pins provide an alternative USB connection, just remember to also connect to 5V and GND.
CircuitPython has an excellent library for USB HID (Human Interface Device) which can be used to create keyboard, mice and media keys. The USB HID library can be used with the GPIO pins, either via direct connection or via a keyboard diode matrix which scans rows of keys for any keypresses.
A keypress will pull a switch at a specific row and column position low and trigger an action based on that key. We tested a simple keyboard interface using a 1 x 4 NeoKey board connected using Stemma QT. We quickly adapted two code examples to create an OBS scene switcher for use when presenting Tom’s Hardware: The Pi Cast. There were no issues and quite frankly, no stress. Everything worked as expected. We pressed a key, a shortcut was triggered, and we saw a pleasant NeoPixel glow.
Why Should I Use KB2040?
In the past, the Arduino Pro Micro was favored. Given its small size, low cost and pin density it was used to create a multitude of USB HID devices. The Arduino IDE isn’t difficult to learn, but if you favor Python, then KB2040 is your best choice. KB2040 is pin and size compatible with the Arduino Pro Micro which means we can create upto 100 key keyboards and reuse existing DIY keyboard chassis.
If we were to sacrifice some GPIO pins then we could also add analog inputs such as potentiometers for tactile volume control. The addition of Stemma QT provides us with the opportunity to chain together different inputs (rotary encoders, sensors and capacitive touch) and outputs (OLED displays, NeoPixels) to create our own truly custom devices. Sure we can do this with an Arduino Pro Micro, but the addition of Stemma QT reduces the inevitable lattice of wires that a keyboard matrix creates.
The Adafruit KB2040 is niche, it is there for the keyboard builders amongst us. The form factor and pin layout means that we can drop this into an existing build and run with it. The Stemma QT connector is a huge draw. Sure we lose a few GPIO pins for our keyboard matrix but we gain easy access to a plethora of enhancements.
The 8MB of QSPI flash storage means we can store plenty of CircuitPython libraries, necessary for use with Stemma QT components. If you are building your first, or your next keyboard, then KB2040 is a cost effective way to get good quality hardware and support from a big name company. If you just need an RP2040 board for hacks, then seriously consider KB2040, because it also works as a generic hobbyist maker board.
Pins D0..D9, A0..A3 and MISO are the same, but the others are not.