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)

mmcb_1.jpg

A tiny media control bar based on ESPHome.

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


Supplies

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

Printing

models.png

Print the following three parts:

  1. mmcb_top.stl
  2. mmcb_bottom.stl
  3. mmcb_knob.stl

Suggested print settings:

  1. Material: PLA
  2. Layer Height: 0.2mm

If you want to customize the OpenSCAD files, clone the repository and modify the .scad files under the enclosure/ directory.

git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/likeablob/mini-media-control-bar

Assembly and Wiring

mmcb_schematics.jpg

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.

# In your esphome config file:
packages:
mmcb:
url: https://github.com/likeablob/mini-media-control-bar
ref: main
files:
- path: mmcb.yaml
vars:
ble_device_name: "mmcb-1"

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:

  1. Key 1 (Left-most):
  2. Default: Meta key
  3. Special: Double-click: Mute
  4. Key 2:
  5. Default: Play/Pause
  6. With Meta: Mute
  7. Key 3:
  8. Default: Previous track
  9. With Meta: Left arrow
  10. Key 4:
  11. Default: Next track
  12. With Meta: Right arrow
  13. Knob:
  14. Default: Volume Up/Down
  15. 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!