Build a Custom ESP32 Macropad: BLE HID Firmware and Hot-Swap Key Matrix Wiring
ESP32-S3 development board
Mechanical keyswitches hot-swap compatible
Hot-swap sockets for mechanical switches
1N4148 diodes pack for key matrix
Keycaps set for macropad
500mAh LiPo battery with protection circuit
TP4056 LiPo charger protection module
- Small OLED display module I2C 0.91 inch
- Perfboard for macropad matrix wiring
Prices and availability as of Nov 22, 9:42 PM ET and subject to change. The price shown on Amazon at the time of purchase applies.
A macropad is a small dedicated keyboard — a handful to a few dozen keys — mapped to shortcuts, macros, or app-specific commands: media controls, a row of DAW transport buttons, copy-paste-undo for a dominant hand, or a full custom layer for CAD or video editing shortcuts. Building one around an ESP32 instead of a cheaper ATmega-based board buys you wireless BLE operation and enough processing headroom to run a small status display, at the cost of a slightly more involved firmware setup than the simplest wired options. This guide covers key matrix wiring with hot-swap sockets, the firmware options that actually support ESP32 today, and the case design decisions that keep a DIY macropad from feeling like a breadboard project once it's done.
Key Matrix Wiring
Even a 12-key macropad benefits from matrix wiring rather than wiring every switch to its own GPIO pin — a matrix lets N+M pins handle up to N×M keys instead of needing one pin per key. Each switch gets a diode in series (cathode toward the column) so the firmware can scan rows and columns without false key reads when multiple keys are pressed at once (ghosting).
| Macropad size | Matrix layout | GPIO pins needed |
|---|---|---|
| 6 keys | 2 rows × 3 columns | 5 (2 row + 3 column) |
| 12 keys | 3 rows × 4 columns | 7 (3 row + 4 column) |
| 16 keys + 2 rotary encoders | 4 rows × 4 columns, encoders on separate pins | 8 for the matrix + 4 for two quadrature encoders |
Use hot-swap sockets rather than soldering switches directly to the PCB or protoboard — they cost very little extra and mean you can try different switch weights and feels (or fix a single bad switch) without desoldering anything. Standard 3-pin or 5-pin MX-style hot-swap sockets fit directly into a perfboard layout if you're not etching or ordering a custom PCB.
Firmware: What Actually Supports ESP32
This is the part that trips people up, because the two most famous custom-keyboard firmware projects have different levels of ESP32 support, and it's worth knowing the real state of things before you commit to a case design around a specific firmware's features.
- QMK: QMK's ESP32 support is limited and not part of its mainstream, well-documented board target list the way AVR and RP2040 boards are — most of the community has moved away from trying to run QMK on ESP32 for BLE projects specifically.
- ZMK: ZMK is Zephyr-based and primarily targets nRF52-series boards (like the common nice!nano) for its mature BLE support; ESP32 support exists through Zephyr's own ESP32 board definitions but is less mature and less widely documented in ZMK's own board list than its nRF52 targets. Treat it as an advanced, community-supported path rather than a guaranteed-to-work option, and check ZMK's current supported-boards list before committing a case design to it.
- Direct Arduino/ESP-IDF BLE HID libraries: for a macropad specifically (rather than a full keyboard with the layer/combo features QMK and ZMK specialize in), a BLE HID keyboard library running directly on the ESP32 under the Arduino framework is the most reliable and best-documented path today. You write the matrix scan loop yourself and send HID keycodes over BLE — less feature-rich than ZMK's layers and combos, but something you can get working in an evening rather than fighting board-support edge cases.
For most macropad builds — a fixed set of shortcut keys rather than a fully programmable layered keyboard — the direct BLE HID library route is the pragmatic choice. Save ZMK for a project where you specifically want its layer and combo system and are willing to work through less-traveled ESP32 board-support documentation.
Adding a Status Display
A small OLED panel wired over I2C is a common macropad addition — showing the active layer, a battery percentage, or which app profile is currently mapped. Keep this secondary to the core key-scanning loop in your firmware: update the display on a slow timer (once a second is plenty) rather than every scan cycle, since redrawing a display every loop iteration adds latency to key detection that you'll actually feel as mushy response.
Power and Battery Life
BLE HID devices live or die on battery life expectations. A macropad left in BLE's connection mode (not advertising, actively paired) draws meaningfully more than one sitting in a deep-sleep/wake-on-keypress state between uses.
| Power approach | Typical runtime (500mAh LiPo) | Tradeoff |
|---|---|---|
| Always-on BLE connection, no sleep | A day or two | Zero wake latency, simplest firmware |
| Light sleep between keypresses, wake on matrix interrupt | Several days to a week+ | Small (usually imperceptible) wake delay on the first keypress after idle |
| USB-powered, no battery | N/A — mains powered | Simplest overall, loses the point of going wireless but removes battery management entirely |
Charge through a small LiPo charge/protection module (a common TP4056-based board) wired to a USB-C input on the case, rather than relying on the ESP32 dev board's own onboard charge circuit if it has one — a dedicated charge module gives you a visible charge-status LED and generally better overpower/overdischarge protection for a device that will sit charging unattended on a desk.
Case Design
A laser-cut acrylic or plywood sandwich case (switch plate, spacer layer, base) is the fastest path from working electronics to a finished-feeling object, and it's easy to iterate on key spacing before committing to a 3D-printed or CNC-milled enclosure. If 3D printing the case instead, design the top plate with standard MX/Choc switch cutout dimensions and at least 1.5mm wall thickness around each cutout — thinner walls there crack under repeated switch insertion force when you're testing different switches during the hot-swap stage.
Safety
The only real hazard in this build is the LiPo battery. Buy a cell with a built-in protection circuit rather than a bare cell, never let the charge module sit unattended for the first charge cycle on a new battery, and inspect the cell for any swelling, punctures, or damage before every use — a punctured or swollen LiPo is a fire risk and should be disposed of at a battery recycling point, not thrown in household trash or kept "just in case."
A macropad is a forgiving first wireless-input-device project: the matrix scanning and HID output are well-trodden ground, and even a basic fixed-shortcut version with no layers or display earns its place on a desk the moment it saves you from a single awkward keyboard-shortcut reach. Start with the direct BLE HID approach to get something working quickly, and treat ZMK's ESP32 path as a later upgrade once you know exactly which layer and combo features you actually want.