On early July, Seeed Studio launched the Seeed Fusion DIY XIAO Mechanical Keyboard Contest, the main goal of the contest is to allow people to design and assembly their own mechanical keyboards using the PCB manufacturing and assembly service provided by Seeed Studio. They also want people to use any of their XIAO boards (SAMD21, RP2040, nRF52840 and ESP32C3) on the design. Without hesitation I started to gather information about the keyboards, and to evaluate the right microcontroller for the task. Instead of thinking about a complex full keyboard, I just wanted to make something with a few keys that would work as a macropad with some key combinations.
The design features a PCB using the XIAO RP2040, based on Raspberry Pi's microcontroller. The circuit has nine MX keys arranged in a 3x3 matrix, which saves IO pins for additional functions. The design also includes a rotary encoder for volume control or zoom. Each key is backlit with a WS2812 RGB LED. Considering the various switch types available, I opted to use hot-swap sockets instead of soldering the switches directly to the board. I also added Truchet tiles designs to the board.
Contest and PCBA Order
The contest guidelines required me to generate Gerber files for manufacturing and assembly files with component positions and BOM. I uploaded everything to Seeed Studio's Fusion website and received confirmation after the files were reviewed. Seeed Studio's support then sent me a discount coupon for the full cost of the PCBs and assembly, making it free of charge. Seeed Studio recommended using parts from the Open Parts Library for faster assembly times, but the SK6812 MINI-E LEDs I used for reverse mounting were not on the Open Parts Library. However, Seeed Studio was able to find and add the parts with the part number and reference PDF.
While waiting for the PCBs, I ordered the other parts and worked on a case design. I used Eagle's tool to export the 3D models to Fusion 360 and created a case based on the PCB model. The case has a base with M2.5 screws to fix the PCB and holes for the XIAO's USB-C port and RESET/BOOT buttons. The cover has holes to pressure-fit the switches and protect the internals. The parts were 3D printed using resin for better resolution, finish, and the option of transparent cases to show the circuit and RGB LEDs.
The PCBs, switches, and printed parts arrived on time, and I was impressed with the quality and detail of the assembled PCBs. After soldering the hot-swap switches and encoder, I tested the keyboard. I connected the XIAO RP2040 to a computer and used a basic MicroPython program to turn on the LEDs and detect key presses.
After confirming that the circuit was working properly, I fixed it to the 3D printed base, being careful not to break the resin while screwing. I then placed the cover and pressed the switches into place, making sure the pins made contact with the hot-swap switches. The base and cover are held together by pressure and switch connections, but glue can be added for additional security. The next step was to write the final program for the XIAO RP2040 and set up the function of each key.
Firmware and Configuration
I chose KMK as the firmware, as it's based on CircuitPython and easy to set up. CircuitPython installation is straightforward, and Adafruit has a helpful tutorial. The KMK installation is shown at KMK's Getting Started page.
It's worth noting that all XIAO boards are pin compatible, so the MacroBoard could be used with any XIAO board that supports CircuitPython and HID USB.