- Early USB keyboards and PS2 keyboards have the same pinout and behavior, so you can use a Pro Mini and the Arduino ps2keyboard demo to read such USB keyboards, either with a passive USB keyboard to PS2 male adapter for less than $1 USD, or via a female USB wired the same. Fancier keyboards don't work as such, at all, hence the possible need for.
- You need a PS2 keyboard female connector. You can get one from an old PC motherboard, simply unsold it with a heat gun. In the picture shown in this step, you can find the function of the needed pins of the PS2 connector. The connection are: Keyboard Data to ESP32 GPIO pin 32; Keyboard IRQ (clock) to ESP32.
- As the C64 keyboard is an 8x8 button matrix, the conversion was quite simple. The use of a virtual-USB library finalises the task and works well. Even the power LED can be illuminated for maximum realism. When reproducing your own C64 keyboard there isn't that much circuitry to add to the keyboard.
Bluetooth LE Keyboard library for the ESP32 (Arduino IDE compatible) - crackerboy/ESP32-BLE-Keyboard. PS2 keyboard library for ESP32 or Arduino. Contribute to michalhol/ps2kbdlib development by creating an account on GitHub.
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.
Esp Keyboard
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.
Esp32 Usb Keyboard Software
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.
This library allows you to make the ESP32 act as a Bluetooth Keyboard and control what it does.
You might also be interested in:
Features
- [x] Send key strokes
- [x] Send text
- [x] Press/release individual keys
- [x] Media keys are supported
- [ ] Read Numlock/Capslock/Scrolllock state
- [x] Set battery level (basically works, but doesn't show up in Android's status bar)
- [x] Compatible with Android
- [x] Compatible with Windows
- [x] Compatible with Linux
- [x] Compatible with MacOS X (not stable, some people have issues, doesn't work with old devices)
- [x] Compatible with iOS (not stable, some people have issues, doesn't work with old devices)
Installation
- (Make sure you can use the ESP32 with the Arduino IDE. Instructions can be found here.)
- In the Arduino IDE go to 'Sketch' -> 'Include Library' -> 'Add .ZIP Library...' and select the file you just downloaded.
- You can now go to 'File' -> 'Examples' -> 'ESP32 BLE Keyboard' and select any of the examples to get started.
Example
API docs
The BleKeyboard interface is almost identical to the Keyboard Interface, so you can use documentation right here:https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
Just remember that you have to use bleKeyboard
instead of just Keyboard
and you need these two lines at the top of your script:
In addition to that you can send media keys (which is not possible with the USB keyboard library). Supported are the following:
Esp32 Usb Keyboard Logitech
- KEY_MEDIA_NEXT_TRACK
- KEY_MEDIA_PREVIOUS_TRACK
- KEY_MEDIA_STOP
- KEY_MEDIA_PLAY_PAUSE
- KEY_MEDIA_MUTE
- KEY_MEDIA_VOLUME_UP
- KEY_MEDIA_VOLUME_DOWN
- KEY_MEDIA_WWW_HOME
- KEY_MEDIA_LOCAL_MACHINE_BROWSER // Opens 'My Computer' on Windows
- KEY_MEDIA_CALCULATOR
- KEY_MEDIA_WWW_BOOKMARKS
- KEY_MEDIA_WWW_SEARCH
- KEY_MEDIA_WWW_STOP
- KEY_MEDIA_WWW_BACK
- KEY_MEDIA_CONSUMER_CONTROL_CONFIGURATION // Media Selection
- KEY_MEDIA_EMAIL_READER
There is also Bluetooth specific information that you can set (optional):Instead of BleKeyboard bleKeyboard;
you can do BleKeyboard bleKeyboard('Bluetooth Device Name', 'Bluetooth Device Manufacturer', 100);
.The third parameter is the initial battery level of your device. To adjust the battery level later on you can simply call e.g. bleKeyboard.setBatteryLevel(50)
(set battery level to 50%).By default the battery level will be set to 100%, the device name will be ESP32 Bluetooth Keyboard
and the manufacturer will be Espressif
.
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.
Esp Keyboard
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.
Esp32 Usb Keyboard Software
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.
This library allows you to make the ESP32 act as a Bluetooth Keyboard and control what it does.
You might also be interested in:
Features
- [x] Send key strokes
- [x] Send text
- [x] Press/release individual keys
- [x] Media keys are supported
- [ ] Read Numlock/Capslock/Scrolllock state
- [x] Set battery level (basically works, but doesn't show up in Android's status bar)
- [x] Compatible with Android
- [x] Compatible with Windows
- [x] Compatible with Linux
- [x] Compatible with MacOS X (not stable, some people have issues, doesn't work with old devices)
- [x] Compatible with iOS (not stable, some people have issues, doesn't work with old devices)
Installation
- (Make sure you can use the ESP32 with the Arduino IDE. Instructions can be found here.)
- In the Arduino IDE go to 'Sketch' -> 'Include Library' -> 'Add .ZIP Library...' and select the file you just downloaded.
- You can now go to 'File' -> 'Examples' -> 'ESP32 BLE Keyboard' and select any of the examples to get started.
Example
API docs
The BleKeyboard interface is almost identical to the Keyboard Interface, so you can use documentation right here:https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
Just remember that you have to use bleKeyboard
instead of just Keyboard
and you need these two lines at the top of your script:
In addition to that you can send media keys (which is not possible with the USB keyboard library). Supported are the following:
Esp32 Usb Keyboard Logitech
- KEY_MEDIA_NEXT_TRACK
- KEY_MEDIA_PREVIOUS_TRACK
- KEY_MEDIA_STOP
- KEY_MEDIA_PLAY_PAUSE
- KEY_MEDIA_MUTE
- KEY_MEDIA_VOLUME_UP
- KEY_MEDIA_VOLUME_DOWN
- KEY_MEDIA_WWW_HOME
- KEY_MEDIA_LOCAL_MACHINE_BROWSER // Opens 'My Computer' on Windows
- KEY_MEDIA_CALCULATOR
- KEY_MEDIA_WWW_BOOKMARKS
- KEY_MEDIA_WWW_SEARCH
- KEY_MEDIA_WWW_STOP
- KEY_MEDIA_WWW_BACK
- KEY_MEDIA_CONSUMER_CONTROL_CONFIGURATION // Media Selection
- KEY_MEDIA_EMAIL_READER
There is also Bluetooth specific information that you can set (optional):Instead of BleKeyboard bleKeyboard;
you can do BleKeyboard bleKeyboard('Bluetooth Device Name', 'Bluetooth Device Manufacturer', 100);
.The third parameter is the initial battery level of your device. To adjust the battery level later on you can simply call e.g. bleKeyboard.setBatteryLevel(50)
(set battery level to 50%).By default the battery level will be set to 100%, the device name will be ESP32 Bluetooth Keyboard
and the manufacturer will be Espressif
.
Credits
Credits to chegewara and the authors of the USB keyboard library as this project is heavily based on their work! Also, credits to duke2421 who helped a lot with testing, debugging and fixing the device descriptor!