3D Printed BLE Media Control Keyboard (ESPHome, OpenSCAD)
by likeablob in Circuits > Gadgets
7 Views, 1 Favorites, 0 Comments
3D Printed BLE Media Control Keyboard (ESPHome, OpenSCAD)

A tiny media control bar based on ESPHome.
- 4 Keys + 1 Rotary Encoder Knob
- Acts as a BLE Keyboard with WiFi connectivity (ESP32-C3 Super Mini)
- Seamless Home Assistant integration via ESPHome
- Customizable 3D Printed Enclosure (designed in OpenSCAD)
Supplies

- 1 x ESP32-C3 Super Mini
- 4 x Low-profile Cherry MX Switches
- 4 x Low-profile Keycaps
- 1 x Generic Mouse Rotary Encoder (3-pin, H5.5mm x W9.5mm)
- Φ1.75mm PLA filament (Used as the shaft for the knob. A short piece is needed.)
- 2 x Magnets (Optional, Φ3mm x 6mm Neodymium for mounting)
- 5 x M2 x 6mm Self tapping screws
- Wire
- LOCTITE
Printing

Print the following three parts:
- mmcb_top.stl
- mmcb_bottom.stl
- mmcb_knob.stl
Suggested print settings:
- Material: PLA
- Layer Height: 0.2mm
If you want to customize the OpenSCAD files, clone the repository and modify the .scad files under the enclosure/ directory.
Assembly and Wiring

Insert the key switches and rotary encoder into the mmcb_top. It is recommended to secure the rotary encoder with instant glue.
Next, solder the wiring between the ESP32-C3 SuperMini, the key switches, and the rotary encoder, as shown in the attached circuit diagram.
You can use wires cut from an old USB cable or something.
Cut a piece of 1.75mm PLA filament about 1cm long to use as the shaft for the rotary encoder. Apply a drop of instant glue to one end of the filament piece and insert it into the rotary encoder.
Apply a few drops of instant glue to the magnets as well, and insert them into the holes on the bottom of the mmcb_bottom.
Finally, secure the mmcb_top and bottom with M2 x 6mm screws, but you may want to perform the next step (software flashing) first.
Software Flashing
If you haven't set up ESPHome yet, install it following the instructions at https://esphome.io/guides/getting_started_hassio.
If you are not familiar with ESPHome: ESPHome is a platform for integrating microcontrollers with Home Assistant. You can add sensors, switches, and various devices to your home automation system simply by adding a few lines in YAML configuration file. While you configure devices using YAML, you can also include C++ snippets for advanced functionality, as ESPHome compiles your YAML configuration into custom firmware (based on Arduino/ESP-IDF).
While ESPHome can be used standalone, it is highly recommended to use it with Home Assistant, which is, by the way, excellent software if you're interested in home automation.
After adding a device from ESPHome, add the following package to the created device configuration file. After uploading again, a Bluetooth keyboard named "mmcb-1" should be detected immediately.
If you want to customize the key assignments, you can override the values using the method described at https://esphome.io/components/packages.html, or simply copy and modify the contents of https://github.com/likeablob/mini-media-control-bar/blob/main/mmcb.yaml into your device configuration file.
The default key assignments are as follows:
- Key 1 (Left-most):
- Default: Meta key
- Special: Double-click: Mute
- Key 2:
- Default: Play/Pause
- With Meta: Mute
- Key 3:
- Default: Previous track
- With Meta: Left arrow
- Key 4:
- Default: Next track
- With Meta: Right arrow
- Knob:
- Default: Volume Up/Down
- With Meta: Right/Left arrow
Test the keys to ensure they work correctly. If there are no issues, screw the top and bottom parts together, and you are done!