← Projects
electronics intermediate 17 days ago ◑ 21 views ◯ 5 min read

Build a Custom ESP32 Macropad: BLE HID Firmware and Hot-Swap Key Matrix Wiring

Build time: A weekend: 3-4 hours for wiring and soldering, 2-3 hours for firmware setup, a few hours for the case
Tools needed: Soldering iron, wire strippers, multimeter, 3D printer or laser cutter for the case, small screwdriver set, hot glue gun
esp32macropadBLE HIDmechanical keyboardhot-swapkey matrixZMKcustom keyboard
Parts List

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 sizeMatrix layoutGPIO pins needed
6 keys2 rows × 3 columns5 (2 row + 3 column)
12 keys3 rows × 4 columns7 (3 row + 4 column)
16 keys + 2 rotary encoders4 rows × 4 columns, encoders on separate pins8 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.

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 approachTypical runtime (500mAh LiPo)Tradeoff
Always-on BLE connection, no sleepA day or twoZero wake latency, simplest firmware
Light sleep between keypresses, wake on matrix interruptSeveral days to a week+Small (usually imperceptible) wake delay on the first keypress after idle
USB-powered, no batteryN/A — mains poweredSimplest 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.