ESP32 Projects
Start a build
Markdown

ESP32 Wi-Fi Touchpad for ESP32-S3

An ESP32 display project for ESP32-S3 involving OLED display.

ESP32-S3ArduinoUnrated
Parts and source

Before you start

Check the exact OLED display configuration against the upstream wiring or parts list.

Upstream README

ESP32 Wi-Fi Touchpad

ESP32 Wi-Fi Touchpad

Turn a ~$5 ESP32-S3 into a real USB touchpad and keyboard — controlled from your phone's browser.

No app to install. No driver. No Bluetooth pairing. The computer just sees a plain USB mouse and keyboard.

Build License: MIT Platform Dependencies Stars

English · العربية


Demo

Watch the demo — typing on a PC from a phone over Wi-Fi

▶ Watch the 24-second demo

Typing into Word on the PC — from the phone, over Wi-Fi. No app, no pairing.


What it is

Plug the board into any computer's USB port. It enumerates as a native USB mouse + keyboard. It also broadcasts its own Wi-Fi network. Connect your phone, open http://192.168.4.1, and you get a full-screen touchpad and on-screen keyboard that drives the computer.

Because it's a real HID device, it works everywhere a USB mouse works — the BIOS/UEFI setup screen, a locked login screen, a Smart TV, a PlayStation, an Android box, a Raspberry Pi with no desktop peripherals. Nothing is installed on the host.

ESP32-S3 board next to the phone running the touchpad Holding the phone as a touchpad and keyboard
The whole setup: one ESP32-S3 board, one USB port, one phone. Landscape layout — touchpad on the left, keyboard on the right.
The interface
Phone (touchpad + keys) Landscape mode
Settings Arabic keyboard

One button in the top bar cycles the view — both, touchpad only, keys only:

Both Touchpad only Keys only

Why this one

There are a lot of "ESP32 remote mouse" sketches. Here's what's different:

This project Typical alternatives
Transport WebSocket, one persistent connection, ~4 ms round trip One HTTP request per movement — visibly laggy
Arabic keyboard Full Arabic 101 layout, including shift layer and diacritics Rare — usually English only
Dependencies Zero. Everything ships with the ESP32 Arduino core WebSockets / AsyncWebServer / ArduinoJson …
Files One .ino. Copy, flash, done Multi-file projects with a data partition to upload
Captive portal Deliberately none — no popup hijacking your phone Captive portal that iOS keeps re-opening
Stuck keys Watchdog releases every key if the phone disconnects Ctrl gets stuck down and you reboot the board

Features

Touchpad

  • One finger — move · tap — left click
  • Two fingers — scroll · two-finger tap — right click
  • Three fingers — middle click · three-finger swipe — switch virtual desktop (Ctrl+Win+←/→)
  • Double-tap and hold — drag and drop
  • Adjustable pointer speed, scroll speed, pointer acceleration, natural scrolling
  • Dedicated left / middle / right buttons and a vertical scroll strip

Keyboard

  • Full Arabic (101) and English (QWERTY) layouts, with the shift layer on both (Arabic diacritics — fatha, damma, kasra, sukun, shadda — are all reachable)
  • Sticky modifiers: tap Ctrl for one-shot, double-tap to lock
  • Fn row (F1–F12), Esc/Tab/Del/Home/End/PgUp/PgDn, arrow keys
  • Macro row: Copy, Paste, Cut, Undo, Select-All, Alt+Tab, Caps
  • Text box — type a whole sentence on your phone's own keyboard and send it in one shot
  • Media keys: volume up/down, mute, play/pause · plus zoom, F11, show desktop

Arabic that actually works The board sends scancodes, not Unicode — exactly like a physical Arabic keyboard. Tapping the ع ⇄ key swaps the on-screen letters and sends the Windows layout-switch shortcut (Alt+Shift or Win+Space, configurable) so the phone and the PC never disagree about the active language.

Interface

  • Bilingual UI (Arabic / English) with full RTL support — it opens in your phone's own language on first run, and remembers whatever you pick after that
  • Touchpad and keyboard on one screen; choose the split (touchpad right/left in landscape, top/bottom in portrait) and drag a slider to set how much space each one gets
  • One button cycles: both · touchpad only · keys only
  • Pure black OLED-friendly theme, haptic feedback, safe-area aware (notches, home indicator)

Reliability

  • WebSocket transport with automatic HTTP fallback if it ever fails
  • Movement is batched once per animation frame, so a fast swipe is one packet, not fifty
  • 4-second watchdog: if the phone walks out of range mid-drag, every key and button is released
  • All keys released when you switch tabs, lock the phone, or close the page
  • hidMux mutex — the WebSocket task and the HTTP task can never call into USB HID at the same time

Hardware

You need an ESP32-S3 (or ESP32-S2) board. This will not work on a classic ESP32 or an ESP32-C3 — those have no native USB peripheral and therefore cannot become a USB HID device.

Recommended Any ESP32-S3 dev board with a USB-OTG port (the port wired to GPIO19/20, usually labelled USB)
Tested on ESP32-S3 DevKitC-1, Waveshare ESP32-S3-LCD-1.47
Also fine ESP32-S2 boards (native USB, untested — reports welcome)
Won't work ESP32 (classic), ESP32-C3, ESP8266 — no native USB device support
Extra parts None. No wiring, no soldering, no display needed.

Two USB ports? Many S3 boards have one port for the USB-to-UART chip and one wired straight to the chip. Flash over either, but for the touchpad to work the board must end up plugged into the native USB (OTG) port. If the mouse doesn't move, try the other port first.


Install

Option A — Arduino IDE
  1. Install the ESP32 core by Espressif (Boards Manager → search esp32) — version 2.0.6 or newer, 3.x preferred.

  2. Download this repo and open esp32-hidpad/esp32-hidpad.ino.

  3. Set these under Tools — the first two are the ones that matter:

    Setting Value
    Board ESP32S3 Dev Module (or your exact board)
    USB Mode USB-OTG (TinyUSB) ← required
    USB CDC On Boot Enabled
    Upload Mode UART0 / Hardware CDC
  4. Hit Upload. No libraries to install — everything used ships with the core.

Option B — arduino-cli
arduino-cli core install esp32:esp32
arduino-cli compile --fqbn "esp32:esp32:esp32s3:USBMode=default,CDCOnBoot=cdc" esp32-hidpad
arduino-cli upload  --fqbn "esp32:esp32:esp32s3:USBMode=default,CDCOnBoot=cdc" -p COM5 esp32-hidpad

USBMode=default is USB-OTG/TinyUSB — that's the mode USBHIDKeyboard and USBHIDMouse need. USBMode=hwcdc will not build.


Use it

  1. Plug the board into the computer you want to control. It appears as a mouse and a keyboard.

  2. On your phone, join the Wi-Fi network:

    Network ESP32-Pad
    Password 12345678
  3. Open http://192.168.4.1 in any browser (or http://hidpad.local).

  4. Move your finger. That's it.

There is intentionally no captive portal, so your phone won't shove a popup browser at you — open the page yourself, and leave and return whenever you like; it reconnects on its own.

Tip: add the page to your home screen. It's a PWA-style full-screen app with its own icon, no browser chrome.

First thing you should change

Open ⚙ → Device network, set your own network name and password, and save. The board reboots its access point; rejoin with the new credentials.

Forgot the password? Hold the BOOT button for 3 seconds — that resets the password to 12345678 (and only the password; your name stays).


Settings

Settings live in two different places, on purpose:

Stored on the board (NVS, survives power loss) Stored in your phone (localStorage)
Network name Pointer speed, scroll speed, acceleration
Network password Natural scrolling, haptics
UI language, keyboard language, layout-switch shortcut
Screen split, touchpad size, view mode

That means every phone that connects keeps its own feel and language — your settings don't follow someone else's hand. Two reset buttons match that split: one clears just this phone's preferences, the other factory-resets the board.


How it works

   Phone browser                ESP32-S3                   Host computer
  ┌──────────────┐          ┌──────────────┐            ┌──────────────┐
  │  touch event │          │  Wi-Fi AP    │            │              │
  │      ↓       │          │  192.168.4.1 │            │  sees a      │
  │  batched per │  ws://   │      ↓       │  USB HID   │  plain USB   │
  │  animation   │─────────▶│  parse       │───────────▶│  mouse +     │
  │  frame       │  :81/ws  │      ↓       │  (TinyUSB) │  keyboard    │
  │              │          │  Mouse.move  │            │              │
  └──────────────┘          │  Keyboard.press           └──────────────┘
                            └──────────────┘

The whole web UI — HTML, CSS, JavaScript, i18n, both keyboard layouts — is a single PROGMEM string served from flash. No SPIFFS, no data upload step, no CDN. The page works with the phone in airplane mode apart from the board's own Wi-Fi.

Full wire protocol (the x=/y=/k=/b= message format, key token names, and the HTTP endpoints) is documented in docs/PROTOCOL.md — useful if you want to build your own client.


Troubleshooting

Symptom Fix
Mouse doesn't move, but the web page loads Board is in the wrong USB port, or USB Mode isn't USB-OTG (TinyUSB).
Sketch won't compile Check USB Mode. On very old cores, set #define USE_MEDIA 0 at the top of the sketch.
Arabic types gibberish Add the Arabic keyboard to Windows and make sure it's the active layout — the board sends scancodes, not letters.
hidpad.local doesn't resolve Use http://192.168.4.1. Android's mDNS support is unreliable.
Laggy pointer Check Link in ⚙ → Info. If it says HTTP, the WebSocket didn't connect — some browsers block it on captive-portal-flagged networks. Open the page in a normal tab.
Forgot the Wi-Fi password Hold BOOT for 3 seconds → back to 12345678.
A key seems stuck down ⚙ → Release all held keys. (The 4-second watchdog also does this automatically.)

More detail in docs/TROUBLESHOOTING.md.


Roadmap

Ideas, in rough order of usefulness. PRs very welcome — see CONTRIBUTING.md.

  • [ ] Station mode — join an existing Wi-Fi network instead of hosting one
  • [ ] More layouts (French AZERTY, German QWERTZ, Persian, Hebrew, Russian)
  • [ ] Gamepad HID mode
  • [ ] Optional on-board display showing the IP and connection state
  • [ ] Multi-touch pinch-to-zoom mapped to Ctrl+scroll
  • [ ] Per-phone macro editor saved in localStorage

Contributing

Issues and pull requests are welcome — bug reports, new keyboard layouts, board compatibility reports. If you got it running on a board that isn't listed above, please open an issue and say so; that's genuinely useful to other people.

License

MIT — see LICENSE. Do whatever you want with it.

If this saved you from buying a wireless keyboard, a ⭐ costs nothing.