An ESP32-S3 powered modular macro keyboard featuring multi-key mapping, voice commands, speech-to-text, and magnetic snap-on expansion modules, all configurable via a companion desktop app.
FunModularKeyboard is a highly customizable macro keypad consisting of 1 main module + 2 magnetic expansion modules. The main unit communicates with expansion modules via a magnetic Pogo-Pin interface (IยฒC bus) with hot-plug support.
| Module | MCU | Description |
|---|---|---|
| Main Module | ESP32-S3 | TFT LCD display, 16-key matrix, rotary encoder, speaker, MEMS mic, Li-Po battery, RGB LEDs, magnetic host interface |
| Module A (ModA) | STM8S103F3 | 3 rotary encoders + 2 slider potentiometers, IยฒC communication via magnetic connector |
| Module B (ModB) | ESP32-S3 | Based on SmartKnob โ brushless motor knob + strain gauge press sensing + LED ring, IยฒC via magnetic connector |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Main Module (ESP32-S3) โ
โ โโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ
โ โ TFT โ โ 16-Key โ โ Rotary Encoder โ โ
โ โ LCD โ โ Matrix โ โ + Button โ โ
โ โโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโโโโ โ
โ โ Mic โ โSpeakerโ โ RGB โ โ Battery โ โ
โ โโโโโโโ โโโโโโโโ โโโโโโโโ โโโโโโโโโโโ โ
โ โโโโโโโโ โโโโโโโโ โ
โ โ USB โ โ BLE โ Dual-Mode HID โ
โ โโโโโโโโ โโโโโโโโ โ
โ โโโโโโโโ Magnetic Pogo-Pin Port โโโโโโโ โ
โ IยฒC + Power + UART โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Module A (STM8) โ Module B (ESP32-S3) โ
โ 3ร Encoders โ BLDC Motor Knob (FOC) โ
โ 2ร Sliders โ Strain Gauge Press โ
โ โ 8ร LED Ring โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- 8 switchable keymap profiles โ toggle between profiles on-the-fly via the rotary encoder for different workflows
- Macro key combos โ one keypress triggers multi-key combinations (e.g.
Ctrl+Win+Dto show desktop) - Multimedia controls โ play/pause, volume, track skip, etc.
- USB HID + BLE dual-mode โ wired or wireless, your choice
- Voice commands โ long-press the MIC key, speak a command, and trigger preset actions via Baidu ASR (e.g. "Open Spotify")
- Speech-to-text โ voice input transcribed to text and sent to the PC
- Custom keyword-to-script bindings supported
A desktop configuration tool that communicates with the keyboard over WiFi/TCP:
- ๐บ๏ธ Visual keymap editor โ drag-and-drop key function configuration
- โ๏ธ Device settings โ WiFi, RGB effects, display brightness/theme, volume, etc.
- ๐ Script engine โ Python script support for one-click app launching and desktop automation
- ๐ Firmware OTA updates โ wirelessly upgrade keyboard firmware
- ๐ PC status monitoring โ real-time CPU usage, disk space, and more shown on the keyboard display
- ๐ต Music lyrics sync โ synchronized lyrics display while music plays
- ๐ HomeAssistant integration โ reserved interface for smart home control
- TFT LCD with LVGL โ rich GUI with multiple theme support
- 16ร WS2812B RGB LEDs โ rainbow, fire, meteor, pulse, and more effects
- Music spectrum visualization โ real-time FFT audio spectrum animation
- Status bar โ clock, battery level, connection status, active keymap profile, etc.
- Module A โ 3 encoders + 2 sliders, ideal for color grading, audio mixing, video editing
- Module B โ brushless motor knob (SimpleFOC), haptic feedback, strain-gauge press sensing, premium tactile feel
- Expansion modules are plug-and-play via the magnetic connector with auto-detection
FunModularKeyboard-OPEN/
โโโ firmware/ # Firmware source code
โ โโโ FunModularKeyboard/ # Main module firmware (ESP32-S3, Arduino)
โ โ โโโ src/ # Core source
โ โ โ โโโ main.cpp # Entry point
โ โ โ โโโ MainTask.cpp/h # Main task scheduler
โ โ โ โโโ DisplayTask.cpp/h # LVGL display task
โ โ โ โโโ MatrixScanner.cpp/h # Key matrix scanner
โ โ โ โโโ RotaryEncoder.cpp/h # Rotary encoder driver
โ โ โ โโโ RGBLightControl.cpp/h # RGB LED effects controller
โ โ โ โโโ USBKeyboardImpl.cpp/h # USB HID keyboard implementation
โ โ โ โโโ BLEKeyboardImpl.cpp/h # BLE keyboard implementation
โ โ โ โโโ VoiceRecognizer.cpp/h # Baidu ASR voice recognition
โ โ โ โโโ AudioAnalyzer.cpp/h # FFT audio spectrum analyzer
โ โ โ โโโ Mic.cpp/h # MEMS microphone driver
โ โ โ โโโ Speaker.cpp/h # Speaker driver
โ โ โ โโโ SerialProtocol.cpp/h # Host app communication protocol
โ โ โ โโโ Configuration.cpp/h # Configuration file manager
โ โ โ โโโ Upgrade.cpp/h # OTA firmware upgrade
โ โ โ โโโ LogManager.cpp/h # Logging system
โ โ โ โโโ modules/ # IยฒC master controller & extensions
โ โ โโโ data/ # SPIFFS data files
โ โ โ โโโ config.ini # Default configuration
โ โ โ โโโ keymap1~8.ini # 8 keymap profiles
โ โ โโโ platformio.ini # PlatformIO build configuration
โ โโโ FunModularKeyboard_ModA/ # Module A firmware (STM8S103F3, IAR)
โ โ โโโ main.c # Main program
โ โ โโโ ec11.c/h # EC11 encoder driver
โ โ โโโ adc.c/h # ADC slider reading
โ โ โโโ i2c.c/h # IยฒC slave communication
โ โ โโโ Uart.c/h # UART debug output
โ โโโ FunModularKeyboard_ModB/ # Module B firmware (ESP32-S3, PlatformIO)
โ โโโ firmware/src/ # Modified SmartKnob-based firmware
โโโ electronics/ # PCB designs (LCSC EDA / EasyEDA)
โ โโโ MainBoard/ # Main board PCB project
โ โโโ ModA/ # Module A PCB project
โ โโโ ModB/ # Module B PCB project
โโโ cad/ # 3D mechanical files
โ โโโ Top.step / Bottom.step # Main enclosure shells
โ โโโ Plate.step # Switch mounting plate
โ โโโ Keycap.step / Keycap2.step # Keycaps
โ โโโ FunModularKeyboard.3mf # 3D printing project file
โ โโโ ModA/ # Module A enclosure
โ โโโ ModB/ # Module B enclosure
โโโ software/scripts/ # Desktop automation scripts
โ โโโ desktop_automation_launch_apps_template.py # One-click app launcher template
โ โโโ desktop_automation_long_press_shutdown.py # Long-press shutdown script
โโโ tools/ # Utility tools
โโโ README.md
| Category | Technology |
|---|---|
| Main MCU | ESP32-S3 (240 MHz, 320 KB RAM, 8 MB Flash) |
| Module A MCU | STM8S103F3 |
| Module B MCU | ESP32-S3 |
| Framework | Arduino (PlatformIO) / IAR (STM8) |
| GUI Library | LVGL 8.3 + TFT_eSPI |
| Keyboard Protocols | USB HID (TinyUSB) + BLE HID |
| Voice Recognition | Baidu Speech Recognition API (REST) |
| Motor Control | SimpleFOC 2.3 |
| Communication | IยฒC (inter-module) / WiFi TCP (host app) |
| File System | SPIFFS |
| RGB Driver | FastLED (WS2812B) |
| FFT Analysis | arduinoFFT |
ESP32 BLE Keyboard โ BLE HID keyboard
FastLED โ RGB LED control
TFT_eSPI โ TFT display driver
lvgl โ Embedded GUI framework
ESP32-audioI2S โ IยฒS audio input
SimpleIni โ INI config file parser
ArduinoJson โ JSON serialization
arduinoFFT โ Fast Fourier Transform
SimpleFOC โ FOC motor control
TLV493D โ 3D magnetic sensor
-
Install PlatformIO IDE (VS Code extension)
-
Clone the repo and navigate to the main firmware directory:
git clone https://github.com/yourname/FunModularKeyboard-OPEN.git
cd FunModularKeyboard-OPEN/firmware/FunModularKeyboard-
Configure WiFi and Baidu Speech API credentials (edit
data/config.inior configure via serial) -
Build and flash:
# Build
pio run
# Flash firmware + upload SPIFFS data
pio run --target upload
pio run --target uploadfsOpen firmware/FunModularKeyboard_ModA/RGB_INIT.eww with IAR for STM8, then build and flash.
cd FunModularKeyboard-OPEN/firmware/FunModularKeyboard_ModB
pio run --target uploadMain module key pin assignments (see platformio.ini and source code for full details):
| Function | GPIO |
|---|---|
| LED Data | 6 |
| LED Power | 36 |
| Encoder CLK | 5 |
| Encoder DT | 21 |
| Encoder SW | 9 |
| IยฒC SDA | 15 |
| IยฒC SCL | 8 |
| Key Matrix Rows | 48, 10, 47, 33, 14 |
| Key Matrix Cols | 35, 34, 7, 13 |
- Connect to the companion desktop app over WiFi
- Use the visual drag-and-drop editor to assign functions to each key (single key, combo, macro, media control, etc.)
- Configure up to 8 different keymap profiles โ switch between them by long-pressing the rotary encoder
- Configure your Baidu API Key and Secret Key in the companion app
- Long-press the MIC-mapped key to start recording
- The recognized speech is matched against preset keywords and triggers the corresponding script
- The companion app pushes new firmware to the keyboard over WiFi
- The keyboard auto-reboots into OTA mode and completes the upgrade
- PCBs: Open the
.epro2project files underelectronics/with EasyEDA - 3D Enclosure: STEP mechanical files and 3MF print-ready files are provided in
cad/ - Magnetic Connector: Uses Pogo-Pin spring-loaded contacts for IยฒC communication and power delivery between modules
- Open-source the companion desktop configuration app
- Community-contributed expansion modules
- Full HomeAssistant integration
- Macro recording and playback
- Support for additional speech recognition engines
- Complete English documentation
Issues and Pull Requests are welcome! If you've designed a cool expansion module, we'd love to see it shared here.
- SmartKnob โ excellent open-source haptic feedback knob project
- LVGL โ lightweight embedded GUI library
- PlatformIO โ cross-platform embedded development ecosystem
- Baidu Speech Recognition โ Chinese speech recognition service