Mivi Agent turns a Raspberry Pi Zero / Zero 2 W into a USB HID keyboard that can be controlled through a web interface or REST API.
The Raspberry Pi connects to a Windows PC through USB and is detected as a normal USB keyboard.
- USB HID Keyboard
- Web UI
- REST API
- Swagger UI
- Automatic startup on boot
- Health endpoint
Future:
- Mouse
- Camera
- WebSockets
- Authentication
- Cloud connectivity
- OTA Updates
- Raspberry Pi Zero W / Zero 2 W
- Raspberry Pi OS Lite
- USB Data cable
- Windows PC
IMPORTANT
Use the USB DATA port on the Raspberry Pi.
Do NOT use the PWR IN port.
git clone https://github.com/<your-account>/mivi-agent.git
cd mivi-agentCreate a virtual environment.
python3 -m venv venvActivate it.
source venv/bin/activateInstall dependencies.
pip install -r requirements.txtEnable USB Gadget Mode.
Edit:
sudo nano /boot/firmware/config.txtAdd
dtoverlay=dwc2
Edit
sudo nano /boot/firmware/cmdline.txtAdd
modules-load=dwc2
after
rootwait
Keep cmdline.txt on a single line.
Reboot.
sudo rebootCopy the script
scripts/usb-keyboard-gadget.sh
to
/usr/bin/usb-keyboard-gadget
Make executable
sudo chmod +x /usr/bin/usb-keyboard-gadgetCopy
systemd/usb-keyboard-gadget.service
to
/etc/systemd/system/
Copy
systemd/mivi-agent.service
to
/etc/systemd/system/
Reload
sudo systemctl daemon-reloadEnable
sudo systemctl enable usb-keyboard-gadget
sudo systemctl enable mivi-agentCopy
udev/99-hidg.rules
to
/etc/udev/rules.d/
Reload
sudo udevadm control --reload-rules
sudo udevadm triggersource venv/bin/activate
uvicorn app.main:app --host 0.0.0.0 --port 8080http://PI-IP:8080
or
http://hostname.local:8080
http://PI-IP:8080/docs
GET /health
Type text
POST /type?text=hello world
Commands
POST /command/select-all
POST /command/copy
POST /command/paste
POST /command/delete
POST /command/backspace
POST /command/tab
POST /command/enter
POST /command/escape
Follow the API logs
journalctl -u mivi-agent -fUSB Gadget
journalctl -u usb-keyboard-gadget -fsystemctl status mivi-agentsystemctl status usb-keyboard-gadgetBrowser
¦
?
FastAPI
¦
?
HID Keyboard
¦
?
Windows PC
mivi-agent/
¦
+-- app/
¦ +-- hid/
¦ +-- services/
¦ +-- static/
¦ +-- templates/
¦ +-- main.py
¦
+-- requirements.txt
+-- README.md
+-- .gitignore
- Mouse support
- Full keyboard layout
- Camera streaming
- Authentication
- Device registration
- WebSocket communication
- OTA Updates
- Multi-device management
- Cloud Dashboard