Inside AI
← Build & Hack
Proposed build / Experimental/DIY Hardware

Use a vision model and an ESP32 mouse to click an Android button

Flash the ready-built mouse firmware onto a classic ESP32, then use an Android screenshot and a vision model to aim at Violet. The image and its checksum have been verified. The full phone-and-board trial still needs a bench test.

Device profile · Espressif ESP32-DevKitC V4 ↗
Start with the documented setup

This is a proposed workflow. Follow the linked official setup, then use the checks below to decide whether it works on your hardware.

Espressif’s top view of the ESP32-DevKitC V4. Labels mark the Micro-USB socket at the left edge, the USB-to-UART bridge beside it, and the ESP32-WROOM-32E module and antenna at the right.
The Micro-USB socket and serial bridge are on the left. The ESP32-WROOM-32E module is on the right. Its shield carries the module name. Original annotated photograph reproduced unchanged. License: https://creativecommons.org/licenses/by-sa/4.0/ Hardware reference for this proposed build; not a result from our test. Espressif Systems · CC BY-SA 4.0 ↗

Set up a target you can check

Open the two-button test page on your own unlocked Android phone. Choose Violet as the target. The page shows a round number, swaps Amber and Violet when you choose Next round, and prints the label of the button that actually received a click. Keep the phone in portrait with the whole test visible. Use two data connections to your computer: one to the phone for screenshots and one to the ESP32’s Micro-B port for programming and serial commands. The ESP32 sends input to the phone over Bluetooth.

You need the classic ESP32-DevKitC-32E, Python 3.10 or later, Android Platform Tools, and a computer capable of running the chosen vision model or calling a vision service. With local inference the screenshot stays on your computer after capture. A hosted model receives screen pixels and may charge per request. Start with just the test page in view. Board and starter budget · Bluetooth volume starter

Download and verify the ready-to-flash firmware

Download the merged mouse firmware (BIN) and its SHA-256 checksum to the same folder. This 687,440-byte image is for a classic ESP32-DevKitC V4 with an ESP32-WROOM-32E and 4 MB flash. It includes the bootloader, partition table and mouse application built with ESP-IDF v6.1.1.

Expected BIN SHA-256 is 0d57703ee1510d0ed8a7947412b65c64c0172525bc29efa2834df284deb828ef. Run the check for your operating system from the download folder. On macOS or Linux, look for OK. In Windows PowerShell, compare the displayed hash with the value above (letter case does not matter). If the check fails, download the files again before flashing.

# macOS or Linux
shasum -a 256 -c esp32-classic-mouse-merged.sha256

# Windows PowerShell
(Get-FileHash esp32-classic-mouse-merged.bin -Algorithm SHA256).Hash

Flash the merged BIN over USB

Use a Python environment with esptool. ESP-IDF is optional for this route. On systems with an externally managed Python installation, create a virtual environment with python3 -m venv .venv and activate it with source .venv/bin/activate. On Windows you can create it with py -m venv .venv and activate it with .venv\Scripts\Activate.ps1 in PowerShell.

Connect the board’s Micro-B port with a USB data cable. Close any serial monitor. Replace BOARD_PORT with the port that appears when you plug the board in, for example /dev/cu.usbserial-… on macOS, /dev/ttyUSB0 on Linux or COM5 on Windows. The Android device ID is used later by adb.

Writing this image replaces the board’s previous firmware and clears settings and Bluetooth pairings stored in its NVS partition. Use address 0x0 for the whole file. It already contains the bootloader at 0x1000, partition table at 0x8000 and application at 0x10000. Run the commands from the download folder. Wait for esptool to report successful data verification and reset. If it stalls at Connecting, hold BOOT, tap EN, then release BOOT when the connection starts. Continue at “Pair the mouse with Android” to try manual movement before running the Python controller. Espressif flashing and merged images

python -m pip install esptool==5.1.0
python -m serial.tools.list_ports
python -m esptool --chip esp32 --port BOARD_PORT write-flash 0x0 esp32-classic-mouse-merged.bin

Optional: build the same firmware from source

Download the ESP32 Bluetooth mouse firmware source (ZIP). It is a complete ESP-IDF project for the ESP32-DevKitC V4 with the ESP32-WROOM-32E module. The archive includes C source, project configuration and a README. Use an ESP-IDF v6.1.1 terminal with the ESP32 toolchain active. Unzip the download, change into the extracted directory, and run the commands below. The version line should report v6.1.1. A successful build prints the flash command and generates the application, partition table and bootloader images. Inside AI compiled a clean copy extracted from this archive using Espressif’s v6.1.1 toolchain for target esp32. The application image, insideai_classic_mouse.bin, was 621,904 bytes; the build also produced the bootloader and partition table. The on-device checks follow below. Espressif toolchain setup To flash your own build, run idf.py -p PORT flash monitor in the project directory and continue at pairing.

unzip esp32-classic-mouse-source.zip
cd esp32-classic-mouse
idf.py --version
idf.py set-target esp32
idf.py build

Capture the Android screen

Enable USB debugging, attach the phone and approve this computer’s debugging key on the phone. In the host terminal, confirm that adb devices lists your phone as device. With multiple devices connected, add -s SERIAL after adb in the capture command. In a binary-safe shell such as Bash or zsh, save a full-resolution PNG. Open it and read the round number and both labels before connecting the model. Repeat after Next round and check that the labels changed sides. Android documents this capture path. Capture on a physical phone for this project remains untested by Inside AI. Android screenshot instructions

adb devices
adb exec-out screencap -p > frame.png

Recognize the labeled button in that frame

Run a vision-language model on the host. It needs the actual PNG and the target label. For a local example, install Ollama, pull qwen3-vl:8b and install the ollama Python client. The snippet asks for a bounding box around Violet, the visible round number and the center of the outlined mouse dot. A missing dot is expected until a mouse moves over the page. Missing or ambiguous targets should produce a null box. Inspect the first prediction against the saved image before enabling any input. The model authors document normalized coordinates from 0 to 1000. Our prompt and its accuracy on phone screenshots have not been tested with the model. Qwen spatial examples · Local model · Python image input

from ollama import chat

prompt = (
    "Read the Android button test. Find the button labeled Violet. "
    "Return JSON with round (integer), label, box [left, top, right, bottom], "
    "and dot [x,y] for the outlined mouse marker. Use full-image coordinates "
    "from 0 to 1000. If the target or dot is missing or ambiguous, return "
    "null for that field. Ignore the status text when locating the button."
)
reply = chat(model="qwen3-vl:8b", format="json", messages=[
    {"role": "user", "content": prompt, "images": ["frame.png"]}
])
print(reply.message.content)

Convert the prediction into an aiming point

Keep the PNG dimensions and orientation with the prediction. For a 1080 × 2400 screenshot and an illustrative box [600, 400, 800, 500], the center is (700, 450) on the normalized scale, or (756, 1080) screenshot pixels measured from the top left. Scale the dot the same way. Compare the two positions in this single image. Reject out-of-range or inverted boxes, mismatched rounds and unreadable labels. A rotation, scroll or new round requires a fresh frame. These numbers illustrate the geometry; they are not model output from a trial.

Pair the mouse with Android

After flashing the prebuilt image, open the board port at 115200 baud with the command below. Press EN once if you missed the startup message. If you used the source build’s flash monitor, keep that monitor open instead.

Wait for “Ready to pair: ESP BT HID1”. From Android Bluetooth settings select ESP BT HID1 and accept the system pairing prompt if shown. If Android remembers an earlier pairing and will not reconnect, forget that device and pair again. Check for “Mouse connected” in the monitor. Keep the board connected to the computer; Android receives mouse input over Classic Bluetooth. This source targets the original ESP32 with Classic Bluetooth support. Board controls · Official flashing guide

python -m serial.tools.miniterm --raw BOARD_PORT 115200

Check the mouse before starting the model

Open the two-button test page and keep it visible on the unlocked phone. In the serial monitor press w, a, s or d to move up, left, down or right. Each character sends ten relative mouse counts; pointer speed determines the distance on screen. The outlined dot should follow movement over the page. Aim at Violet, then press q once. The supplied firmware sends left-button down, waits about 30 ms, then sends left-button up at the same location. A successful manual trial shows “Round 1 · Clicked Violet” if you started in round 1. A Bluetooth connection message alone cannot confirm a click.

For the model trial, tap Next round on the phone to clear the receipt and swap the buttons. Note the new round number. Move the mouse once over the test area so the marker is visible, then exit the monitor with Ctrl+]. The Python controller needs exclusive access to the board port. If reconnecting the port resets your adapter, wait for Android to reconnect and check the marker again.

Run one round with the Python controller

Save the Python controller on the computer. Install pyserial in your Python environment. Start the local Ollama service and pull qwen3-vl:8b. The controller uses its local HTTP API. Check adb devices, approve USB debugging on the phone, and use the ID of the device marked device. Use the same board port you used to flash; the controller opens it at 115200 baud and sends one character at a time without a newline.

Run the command below from the folder containing the Python file. Replace ANDROID_SERIAL, BOARD_PORT and the example round number with the values from your setup. Choose a new output folder for each trial. Leave the page in portrait and still. The host saves each PNG and model reading, moves toward the button, takes another screenshot and sends at most one q. It stops after at most 20 moves. If the model cannot locate the outlined dot or the requested label, inspect the last frame before starting a new trial.

python -m pip install pyserial
ollama pull qwen3-vl:8b
adb devices
python -m serial.tools.list_ports
python esp32-android-button.py --device ANDROID_SERIAL --port BOARD_PORT --round 2 --label Violet --output trial-02

Verify the click after the buttons swap

Open after.png in the new trial folder. A pass requires the phone to show the same round and exactly the requested button, for example “Round 2 · Clicked Violet”. Compare the saved frame and the model’s printed readback with the phone. A model reply alone cannot confirm a physical click. Tap Next round, move the pointer back onto the test page to make the marker visible, then repeat with a fresh folder and the new round. Confirm a hit with Violet on each side and try Amber.

If the phone never appears in adb devices, fix screenshot access first. If serial open fails, close the monitor and check the board port. If manual movement works but the automatic trial stops, inspect frame-00.png and its reading JSON for a missing dot, wrong label or stale round. If the dot reaches the button but the receipt stays unchanged, repeat the manual q test. Record phone model, Android version, pointer speed, flashed image hash and model tag alongside the images.

Evidence and open tests

Inside AI built the exact downloadable source with ESP-IDF v6.1.1 for target esp32. Each of the three images in the prebuilt BIN matched its original build artifact byte for byte at the recorded flash offset. We also checked the padding, size and SHA-256 on the host. The source ZIP checksum below applies to the optional rebuild. Browser tests checked marker movement, swapping the buttons and round-specific receipts. With synthetic frames and model replies, the unchanged Python controller wrote exactly w, a, s, d and q through pySerial to a virtual serial port at 115200 baud. A separate host simulation checked the firmware’s directional reports and left-button press/release.

The build did not involve flashing a physical board. Android capture on a real phone, pairing, physical cursor motion, click press/release, model accuracy and the full phone–ESP32 trial still need a bench test. No measured reliability or latency is claimed.

Source ZIP SHA-256
6c1d8e969df14f4dadd0c5d702517b33b36c8609c2d528c32d519a67e31d78dc

Primary sources

Espressif · ESP32-DevKitC V4 board guide Espressif · Bluetooth HID device example Espressif · Volume report implementation Android Developers · Capture a device screenshot Qwen · Spatial understanding with Qwen3-VL Ollama · Send an image from Python Ollama · Qwen3-VL 8B