Here’s a clean, professional, and technical-style README.md you can use directly for your GitHub repository of this BLE keyboard ESP32 project 👇
This project turns an ESP32 into a Bluetooth Low Energy (BLE) Keyboard (HID device) capable of sending keystrokes, system, and media control commands to a paired device such as a computer, smartphone, or tablet.
It uses the BleKeyboard library for Arduino to emulate a standard Bluetooth keyboard.
| Function | Description |
|---|---|
| BLE Keyboard Emulation | ESP32 acts as a standard Bluetooth keyboard (HID). |
| Automatic Text Sending | Sends "Hello world" every loop when connected. |
| Keyboard Key Events | Sends standard keys such as Enter, Ctrl, Alt, Del, etc. |
| Media Key Events | Controls system media keys such as Play/Pause. |
| Connection Detection | Operates only when a BLE client is connected. |
| Debug via Serial | Prints log messages on the serial console for debugging. |
When powered on:
- ESP32 starts advertising as a BLE keyboard.
- You can pair it with your computer or phone (shows up as "ESP32 Keyboard").
- Once connected:
- Types
"Hello world". - Presses Enter.
- Sends Play/Pause media key.
- (Optionally) Sends Ctrl+Alt+Del combination.
- Types
- ESP32 development board (with BLE support)
- USB cable for programming
- (Optional) Push button or input device if adding manual triggers
-
Arduino IDE or PlatformIO
-
BleKeyboard Library
Install via Arduino Library Manager or clone manually:https://github.com/T-vK/ESP32-BLE-Keyboard
🧱 Code Explanation Main Sections
- Initialization BleKeyboard bleKeyboard;
void setup() { Serial.begin(115200); Serial.println("Starting BLE work!"); bleKeyboard.begin(); }
Starts the BLE service and serial logging.
- Main Loop if (bleKeyboard.isConnected()) { bleKeyboard.print("Hello world"); bleKeyboard.write(KEY_RETURN); bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE); }
Checks if connected.
Sends text, Enter key, and Play/Pause media key.
- (Optional) Modifier Keys bleKeyboard.press(KEY_LEFT_CTRL); bleKeyboard.press(KEY_LEFT_ALT); bleKeyboard.press(KEY_DELETE); delay(100); bleKeyboard.releaseAll();
Demonstrates sending multiple modifier keys (e.g. Ctrl+Alt+Del).
🧪 Example Serial Output Starting BLE work! Sending 'Hello world'... Sending Enter key... Sending Play/Pause media key... Waiting 5 seconds...
🧩 Future Enhancements
Add GPIO trigger button to send keystrokes manually.
Add custom key sequences from configuration file or serial input.
Extend to BLE Mouse or BLE Gamepad mode.
Some key combinations (e.g. Ctrl+Alt+Del) are blocked on Windows for security reasons.
BLE HID may not be supported on some Android versions without user permission.
Works best with ESP32-WROOM, ESP32-S3, or similar boards supporting BLE.
🧑💻 Example Use Cases
Wireless automation keyboard
Presentation or media remote
Test keyboard input automation
Security and accessibility tools
Author: JExplorer Platform: ESP32 BLE HID (Arduino / PlatformIO) Repository: https://github.com/kojedt/ESP32-BLE-Keyboard