Introduction: 11 Steps to Easily Create Your Own ESP32 Mechanical Keyboard
Have you heard of the custom mechanical keyboard? It's like the haute couture of keyboards, tailored to your preferences and needs, resulting in a one-of-a-kind, personalized mechanical masterpiece. I recently realized that my room was a snoozefest, so I decided to spice things up by DIYing an RGB keyboard. While most mechanical keyboards rely on either the Arduino Micro or USB host expansion board as their main controller, I went for the fancy-pants ESP32-S3 chip. Why? Because it comes with integrated 2.4GHz WiFi and Bluetooth 5 capabilities, enabling long-distance communication and providing rock-solid stability. In this tutorial, I'll give you the lowdown on how to use the ESP32-S3 chip as the main controller to create the keyboard of your dreams. Get ready to type in style!
Supplies
The following the components and their quantities required for this tutorial:
Board Kit (PCB board, acrylic shell) x 1
ESP32-S3 chip x 1
Mechanical keyboard base x 87
Mechanical keyboard switches x 87
Mechanical keyboard keycaps x 87
6028 SK6812 RGB LED beads x 87
1206 SMD LED beads (RED) x 6
Type-C interface x 3
Toggle switch x 1
Other components (resistors, capacitors) x n
Step 1: PCB Design
Let's talk about the different types of mechanical keyboards, which come in all shapes and sizes - from the full 107-key behemoth to the compact and sassy 87-key model. For this tutorial, we'll be focusing on the latter. Here's a look at the PCB schematic we'll be using:
But wait, there's more! I've gone ahead and added a battery power supply to my keyboard, so I can use it on-the-go and show it off to my friends wherever I please. Who said keyboards can't be stylish AND functional?
Step 2: PCB Ordering
After confirming that the PCB schematic is correct, the next step is to order the PCB. Fortunately, Elecrow has recently launched a spring promotion for mechanical keyboards in 2023. PCBs can be ordered for only $9.9 without size restrictions. For more information, please visit:
https://www.elecrow.com/Elecrow-Mechanical-Keyboards-2023-Spring-Promotion
In addition, the promotion also supports $1 acrylic plate ordering.
The image on the right shows the PCB product received after ordering from Elecrow.
Step 3: Component Soldering
According to the PCB schematic and functional requirements, solder the ESP32-S3 chip, mechanical keyboard base, and other electronic components onto the PCB board.
Here are a few things to note:
1. All components should be soldered on the back of the mechanical keyboard (distinguished by the silk screen);
2. The position and orientation of the ESP32-S3 chip when soldering;
3. The RGB lights are soldered in reverse-mount, with the bright side facing the front of the mechanical keyboard;
4. The direction of the mechanical keyboard base (wider on the left and narrower on the right);
5. The LED lights are also soldered in reverse-mount, and the green stripe should be facing left (the end with the green stripe is the negative pole).
Step 4: Frame Design
Based on the PCB schematic and the actual positions and dimensions of each component, design the acrylic frame structure. Taking into account factors such as the insertion and removal of mechanical keyboard switches, the exposed Type-C interface, and the normal display of indicator lights, the final design is a structure with two upper layers and two lower layers.
Step 5: Frame Assembly
Stack the four acrylic plates and the PCB board in the correct order, and then use screws and nuts to fix the whole assembly together through the reserved screw holes.
Since some keys on the keyboard require stabilizers, they need to be fixed on the PCB board before assembling the acrylic frame.
Step 6: Switch Assembly
Align each mechanical keyboard switch with the corresponding socket on the keyboard base and install them one by one.
It is important to note that both pins of the mechanical keyboard switch must be fully inserted into the two slots on the keyboard base, otherwise the key will not function properly.
Step 7: Software Configuration
Next, let's start burning the program to the PCB board!
Connect any Type-C connector on the mechanical keyboard PCB to a computer, and open the Arduino IDE software. Add the following URLs to the 'Additional Boards Manager URLs' window:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then search for 'esp32' in the Board Manager and install it. After installation, select 'ESP32S3 Dev Module' as the main board.
Step 8: Bluetooth Address Configuration
Before uploading the program, you need to find the Bluetooth device address of your computer, and then open the 'keyboard.h' program to change the address in the picture to the Bluetooth device address of your computer.
If your Bluetooth device address starts with "00", "01", or "11", you need to open the main program "keyboard_main.ino", comment out the code "esp_base_mac_addr_set(mac);" and uncomment the code "esp_ble_gap_set_rand_addr(mac);".
Step 9: Upload Program
Open the main program 'keyboard_main.ino' and click on the 'Upload' button to upload the program (The complete program is available in the attachment).
Here we only need to upload this one program, the other programs are function programs that can be called directly through the main program. You can also refer to the 'readme.txt' file in the documentation to understand the functions of each function program.
Attachments
Step 10: Function Debugging
After the program is successfully uploaded, test each component to ensure that its corresponding function is working properly.
If the RGB light is not working properly, refer to the PCB diagram to find the faulty RGB light closest to the control pin line, and use a multimeter to check for voltage. If no voltage is detected, it may need to be re-soldered and then tested again.
Similarly, if some keys are not working properly, try unplugging the switches and plugging them back in. If they still don't work, use a multimeter to check for continuity between the two ends of the keyboard base, and decide whether to re-solder based on the results of the test.
Step 11: Install Keycaps
After the check is complete and all functions are confirmed to be working properly, you can install the keycaps. According to the key mapping diagram of the 87-key keyboard, assemble all the keycaps on the corresponding axis bodies. At this point, the ESP32 mechanical keyboard is complete.
Step 12: Brief Function Description
The ESP32 mechanical keyboard is powerful, versatile, and has high transmission stability. It can be summarized as follows:
1. It supports both wired and Bluetooth connections, and can pair with up to three devices simultaneously via Bluetooth.
2. It has three Type-C interfaces reserved, which can meet the communication needs of users in different directions.
3. When using Bluetooth connection, it can be powered by an external power supply device through the Type-C interface, or by an external lithium battery through the battery interface on the back.
4. The power of the keyboard can be controlled by a toggle switch. The keyboard will also automatically enter sleep mode when there is no operation for a long time.
5. Various backlighting effects, volume control, Bluetooth switching, and system switching can be achieved through combination keys.
Step 13: Use With Battery
Finally, let's take a look at the performance when powered by the battery. Yes, it's really cool because it turns your keyboard into a truly wireless one, without the need for a power cord. So, come on and make your own keyboard now!