Skip to main content

ESP32 BLE HID Bridge — Control mouse & keyboard via WiFi TCP or Bluetooth SPP through an ESP32

Project description

ESP32 HID Bridge

Control mouse & keyboard input through an ESP32 acting as a BLE HID device. Communicate with the ESP32 over WiFi TCP or Bluetooth SPP from Python.

Features

  • Mouse: move, click, press/release, scroll
  • Keyboard: press, release, tap, multi-key combos (shortcuts)
  • Dual Mode: WiFi TCP (~1-5ms) or Bluetooth SPP (~10-50ms)
  • Auto-detect: Finds ESP32 Bluetooth COM port automatically
  • Context manager: Use with with statement for auto-cleanup

Installation

# WiFi only (no extra dependencies)
pip install esp32-hid-bridge

# WiFi + Bluetooth SPP support
pip install esp32-hid-bridge[bluetooth]

Quick Start

WiFi TCP Mode

from esp32_hid_bridge import ESP32Bridge

# Connect via WiFi
bridge = ESP32Bridge(host="192.168.1.100")

# Mouse
bridge.mouse_move_relative(100, 50)
bridge.mouse_click()
bridge.mouse_click("right")
bridge.mouse_scroll(3)

# Keyboard
bridge.key_tap("a")
bridge.key_multi_press(["ctrl", "c"])  # Ctrl+C

bridge.close()

Bluetooth SPP Mode

from esp32_hid_bridge import ESP32Bridge

# Connect via Bluetooth
bridge = ESP32Bridge(port="COM8")
bridge.mouse_click()
bridge.close()

Context Manager

from esp32_hid_bridge import ESP32Bridge

with ESP32Bridge(host="192.168.1.100") as bridge:
    bridge.mouse_click()
    bridge.key_tap("enter")
# Connection is closed automatically

Auto-detect Bluetooth

from esp32_hid_bridge import ESP32Bridge

# Scans all COM ports for an ESP32 with PONG response
bridge = ESP32Bridge()

Configuration via Environment Variables

# Set once, no need to pass host= every time
set ESP32_HOST=192.168.1.100
set ESP32_TCP_PORT=8266     # optional, default 8266
set ESP32_PORT=COM8          # for Bluetooth mode
bridge = ESP32Bridge()  # Reads from env vars

Save/Load Config File

from esp32_hid_bridge import ESP32Bridge
from esp32_hid_bridge.bridge import save_config, load_config

# Save host to config file
save_config("esp32_config.json", ESP32_HOST="192.168.1.100")

# Load and connect
bridge = ESP32Bridge(config_path="esp32_config.json")

API Reference

ESP32Bridge

Method Description
mouse_move_relative(dx, dy) Move cursor by (dx, dy) pixels
mouse_click(button="left") Click a button (left, right, middle)
mouse_press(button="left") Press and hold a button
mouse_release(button="left") Release a button
mouse_scroll(wheel) Scroll (positive=up, negative=down)
key_press(key) Press and hold a key
key_release_all() Release all pressed keys
key_tap(key, delay_ms=35) Tap a key (press + delay + release)
key_multi_press(keys) Press multiple keys then release
ping() Ping ESP32, returns True if alive
close() Close the connection
is_open() Check if connected
mode Current mode: "wifi", "bluetooth", or None

Supported Keys

All standard keys including: a-z, 0-9, enter, esc, tab, space, backspace, delete, insert, home, end, pageup, pagedown, arrow keys (up, down, left, right), f1-f12, modifiers (ctrl, shift, alt, win), and common symbols.

ESP32 Firmware

Flash the included Arduino firmware (examples/firmware/esp32_bt_hid.ino) to your ESP32. Requirements:

  • Board: ESP32 Dev Module
  • Partition: Huge APP (3MB)
  • Library: ESP32-BLE-Combo by blackketter

Setup

  1. Open esp32_bt_hid.ino in Arduino IDE
  2. Change WIFI_SSID and WIFI_PASS to your WiFi credentials
  3. Flash to ESP32
  4. Find the IP address from Serial Monitor or your router

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esp32_hid_bridge-1.0.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

esp32_hid_bridge-1.0.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file esp32_hid_bridge-1.0.0.tar.gz.

File metadata

  • Download URL: esp32_hid_bridge-1.0.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for esp32_hid_bridge-1.0.0.tar.gz
Algorithm Hash digest
SHA256 036ac40057d2dcb6773a3926d153b844ad708cadc8ac7dda4cab7916af8d8519
MD5 420c89ef83d3c814037b084ec3d7d229
BLAKE2b-256 50bb539b0b976a7ea0993d7a15df3e85a7290464deae01c7fcdc0bd34c3ea5c5

See more details on using hashes here.

File details

Details for the file esp32_hid_bridge-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for esp32_hid_bridge-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92d4b68ae72e0c1b35a6d493d1da16d94c3eed2030a95eb05ea85025434cd0f2
MD5 855db17fc9a5855aac22ce53b886ecde
BLAKE2b-256 44bc07bee861a6335497d8e8488a5c64b3730244c5e2b889dfb87ddb803290b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page