Most people associate the ESP family of microcontrollers with WiFi, which makes sense as they’ve become the solution of choice for getting your project online quickly and easily. But while the WiFi capability might be the star of the show, the ESP32 also comes equipped with Bluetooth; we just don’t see people using it nearly as often. If you’re looking to get started using Bluetooth on the ESP32, then this simple wireless macro keypad from [Brian Lough] would be a great way to get started.
From a hardware standpoint, this project is incredibly straightforward. All you need to do is connect a membrane keypad up to the GPIO pins on the ESP32. Adding in a battery is a nice touch, and you probably would want to put it into a enclosure of some sort, but as a proof of concept it doesn’t get much easier than this. In this case [Brian] is using the TinyPICO board, but your personal ESP32 variant of choice will work just as well.
The rest of the project is all software, which [Brian] walks us through in the video after the break. There’s a preexisting library for Bluetooth Human Interface Device (HID) emulation on the ESP32, but it needs to be manually installed in the Arduino IDE. From there, he demonstrates how you can build up a functioning keyboard, including tricks such as sending multiple virtual keys at once.
In the past we’ve seen the ESP32 used to create a Bluetooth game controller, but the ability to emulate a keyboard obviously offers quite a bit more flexibility. With a practical demonstration of how easy as it is to turn this low-cost microcontroller into a wireless input device, hopefully we’ll start seeing more projects that utilize the capability.
I’ve been looking for a keyboard that can do USB and Bluetooth for a long time so that I can switch between my Desktop Gaming machine and my work laptop. I might just have to build my own mechanical keyboard now…
FYI, Joric in r/MechanicalKeyboards [has designed](https://www.reddit.com/r/MechanicalKeyboards/comments/bby5y4/nrfmicro_nrf52840based_hardware_usb_support_vs/) a ProMicro-pin-compatible module using the nRF52840; other beefy BLE-capable MCU modules exist too.
I have a rechargeable folding backlit keyboard that does just that, can work either as a bluetooth keyboard or as an USB keyboard (handy if you need to edit bios settings, for example). I won’t link it here, because there’s tons of the things, rebranded to hell, available by the usual online sellers. Mechanically they are not exactly ideal for gaming or long typing, but using them as brains for another keyboard should be in the realm of the possible.
I have a Keychron K4 that does that. Supports 3 bluetooth devices, or flip a switch to change to USB. Mac/PC compatible.
Take a look at this project: https://github.com/abelykh0/esp32-BLEKeyboard. I was able to buy PS/2 keyboard in a local thrift store for $3.
I’m working on a very similar project to reuse an old Dell laptop keyboard and add bluetooth with an ESP32. This project should be a handy reference to help me later, once I finally manage get the FPC connector soldered to the PCB.
To me, pairing a readily available BT keyboard to an ESP32 would be much more useful, same for USB-HID Keyboards, i.e. with the ESP32 acting as a host
With some more hacking (mouse emulation) this would make an excellent addition to an automated test setup, for simulating user input. Since the simulation is done in hardware, you can put the actual deployed hardware in the test rig.
If I were making a bluetooth keyboard simply to be used as a keyboard, I wouldn’t want the power overhead of an ESP32. There are cheap BLE 4.0 modules available on ebay for a buck or two, and I’ve had good luck with the HM-10. They’re based on a TI CC2541 chip, and it’s possible to flash custom firmware to them so they can be used standalone rather than communicating via serial to an arduino. They take very little power. If you search “geekhack hm-10” you can find a bunch of resources where people have used these to bluetooth-ify a bunch of custom mechanical keyboards.
ESP-32 can emulate many BLE devices, so keyboards are just a beginning. Just have a look at the list of GATT services and characteristics – the list goes on and on… I am using one as a traning bike cadence and distance meter, for example.
Hi all – perhaps I missed something, but what target Board and Processor should I select in the Arduino IDE when uploading the template sketch? Default Genuine Arduino did not do the trick and failed on upload. Was this covered in a different video?
It will be an ESP32 board, not the default Uno board (if that’s what you were saying). You’ll need to put the ESP32 into the board manager.
Someone use this with Raspberry Pi?
I can connect ESP32 with Pi, but can’t “print”.
In my iPhone works.
Could this library be used to send joystick commands instead? I’m modifying a rc car controller for use with video games.
I have been looking for a way to automatically lock a screen (send Win-L to WindowsOS or cmd-ctrl-q on MacOS) automatically when no one is presence. This hack may path a way to get ESP32 connected to LD2410B Human Presence to do just that.