Adafruit’s latest RP2040-based board diverges from form factors like the 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 commonly 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 through the 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 money, and what can we do with it? We put Adafruit’s KB2040 to the test and took it for a test drive, including to control OBS during our live-streamed The Pi Cast show.
Adafruit KB2040 Specifications:
|SoC||RP2040 32-bit Cortex M0+ dual core running at 125MHz @ 3.3V logic and power. 264KB 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|
|Flow||5V over USB-C|
|RAW output with 500mA fused output, user bypassable.|
|3.3V regulator with 500mA peak current output|
|Functions||1 x NeoPixel|
|Bootloader / User Programmable Button|
|Dimensions||1.4 x 0.7 x 0.2 in (35 x 17.8 x 4.9mm)|
Using Adafruit KB2040
KB2040, as the name suggests, is designed so that you can create your own custom keyboard. Whether you prefer Cherry MX Red, Blue, Kailh or Gateron switches, that choice is left to the maker, but the KB2040 doesn’t care.
With 20 GPIO pins (including Stemma QT) on offer, you can create up to 100 key arrays, enough for most keyboard warriors. The selection of GPIO pins is considered, just enough for a keyboard, and more than enough if you want to use the $9 board for other maker projects. The 18 GPIO pins around the board are broken out in two ways. The traditional through hole is ready for header pins and castellations allowing KB2040 to be surface soldered to a printed circuit board, the latter desirable for those looking to integrate KB2040 into a sleek build.
If you want to take advantage of the 5V provided via 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 more current, there is a jumper on the bottom of the board that can be soldered shut to allow a current draw of up to 2A, which is handy for NeoPixels.
Finally, we have two additional USB breakout pins, D+ and D-. These two pins provide an alternate USB connection, don’t forget to connect to 5V and GND as well.
CircuitPython has an excellent library for USB HID (Human Interface Device) that can be used to create keyboards, mice, and media keys. The USB HID library can be used with the GPIO pins, either through a direct connection or through a keyboard diode array that scans rows of keys for keystrokes.
A key press turns off a switch at a specific row and column position low and triggers an action based on that key. We tested a simple keyboard interface using a 1 x 4 NeoKey board connected to Stemma QT. We quickly modified two code samples to create an OBS scene switch for use in presenting Mujahid Tricks: The Pi Cast. There were no problems and frankly, no stress. Everything worked as expected. We pressed a key, a shortcut was activated and we saw a pleasant NeoPixel glow.
Why should I use KB2040?
In the past, the Arduino Pro Micro was a favorite. Given its small size, low cost and pin density, it was used to make a large number of USB HID devices. The Arduino IDE is not difficult to learn, but if you prefer Python, KB2040 is the way to go. KB2040 is pin and size compatible with the Arduino Pro Micro, which means we can make up to 100 keyboards with keys and reuse existing DIY keyboard chassis.
If we sacrificed some GPIO pins, we could also add analog inputs, such as potentiometers for tactile volume control. The addition of Stemma QT gives us the ability to link different inputs (rotary encoders, sensors and capacitive touch) and outputs (OLED displays, NeoPixels) together to create our own truly custom devices. Of course we can do this with an Arduino Pro Micro, but the addition of Stemma QT reduces the inevitable mesh that creates a keyboard matrix.
The Adafruit KB2040 is a niche, it’s for the keyboard builders among us. The form factor and pin layout allows us to put this in an existing build and work 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 improvements.
The 8 MB QSPI flash storage allows us to store many CircuitPython libraries needed for use with Stemma QT components. If you’re building your first or next keyboard, KB2040 is a cost-effective way to get good quality hardware and support from a major company. If you only need an RP2040 board for hacks, seriously consider KB2040 as it also works as a generic board for hobbyists.