You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2157 lines
53 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Open and cheap DIY IP-KVM on Raspberry Pi">
<meta name="author" content="Maxim Devaev">
<link rel="canonical" href="https://pikvm.github.io/pikvm/arduino_hid/">
<link rel="prev" href="../3d_printing/">
<link rel="icon" href="../_assets/favicon.ico">
<meta name="generator" content="mkdocs-1.6.0, mkdocs-material-9.5.19">
<title>Arduino HID - PiKVM Handbook</title>
<link rel="stylesheet" href="../assets/stylesheets/main.66ac8b77.min.css">
<link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=arial,+sans-serif:300,300i,400,400i,700,700i%7Cmonospace:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"arial, sans-serif";--md-code-font:"monospace"}</style>
<link rel="stylesheet" href="../_assets/user.css">
<script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="pink">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#serial-hid" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href=".." title="PiKVM Handbook" class="md-header__button md-logo" aria-label="PiKVM Handbook" data-md-component="logo">
<img src="../_assets/logo.png" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
PiKVM Handbook
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Arduino HID
</span>
</div>
</div>
</div>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<a href="javascript:void(0)" class="md-search__icon md-icon" title="Share" aria-label="Share" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7 0-.24-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91 1.61 0 2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08Z"/></svg>
</a>
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
</button>
</nav>
<div class="md-search__suggest" data-md-component="search-suggest"></div>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://github.com/pikvm/pikvm" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
</div>
<div class="md-source__repository">
pikvm/pikvm
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href=".." title="PiKVM Handbook" class="md-nav__button md-logo" aria-label="PiKVM Handbook" data-md-component="logo">
<img src="../_assets/logo.png" alt="logo">
</a>
PiKVM Handbook
</label>
<div class="md-nav__source">
<a href="https://github.com/pikvm/pikvm" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
</div>
<div class="md-source__repository">
pikvm/pikvm
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_1" >
<label class="md-nav__link" for="__nav_1" id="__nav_1_label" tabindex="">
<span class="md-ellipsis">
Getting started
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_1_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_1">
<span class="md-nav__icon md-icon"></span>
Getting started
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_1_1" >
<label class="md-nav__link" for="__nav_1_1" id="__nav_1_1_label" tabindex="0">
<span class="md-ellipsis">
Device guides
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_1_1_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_1_1">
<span class="md-nav__icon md-icon"></span>
Device guides
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../v4/" class="md-nav__link">
<span class="md-ellipsis">
PiKVM V4 Mini & Plus
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../v3/" class="md-nav__link">
<span class="md-ellipsis">
PiKVM V3 HAT
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../v2/" class="md-nav__link">
<span class="md-ellipsis">
DIY PiKVM V2
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../v1/" class="md-nav__link">
<span class="md-ellipsis">
DIY PiKVM V1
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../first_steps/" class="md-nav__link">
<span class="md-ellipsis">
First steps
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../auth/" class="md-nav__link">
<span class="md-ellipsis">
Authentication
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../faq/" class="md-nav__link">
<span class="md-ellipsis">
FAQ & Troubleshooting
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_2" >
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="">
<span class="md-ellipsis">
Networking
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Networking
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_2_1" >
<label class="md-nav__link" for="__nav_2_1" id="__nav_2_1_label" tabindex="0">
<span class="md-ellipsis">
Internet access
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_2_1_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_2_1">
<span class="md-nav__icon md-icon"></span>
Internet access
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../port_forwarding/" class="md-nav__link">
<span class="md-ellipsis">
Port forwarding
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../tailscale/" class="md-nav__link">
<span class="md-ellipsis">
Tailscale VPN
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../cloudflared/" class="md-nav__link">
<span class="md-ellipsis">
Cloudflare Tunnel
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../wifi/" class="md-nav__link">
<span class="md-ellipsis">
Setting up Wi-Fi
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../letsencrypt/" class="md-nav__link">
<span class="md-ellipsis">
Let's Encrypt certificates
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="">
<span class="md-ellipsis">
Video
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Video
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../edid/" class="md-nav__link">
<span class="md-ellipsis">
Tuning HDMI EDID
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../pass/" class="md-nav__link">
<span class="md-ellipsis">
HDMI passthrough
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../webrtc/" class="md-nav__link">
<span class="md-ellipsis">
H.264 / WebRTC
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../video/" class="md-nav__link">
<span class="md-ellipsis">
Working with video
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../audio/" class="md-nav__link">
<span class="md-ellipsis">
HDMI audio
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_4" >
<label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="">
<span class="md-ellipsis">
Peripheral devices
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
Peripheral devices
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_4_1" >
<label class="md-nav__link" for="__nav_4_1" id="__nav_4_1_label" tabindex="0">
<span class="md-ellipsis">
Keyboard & mouse
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_4_1_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_4_1">
<span class="md-nav__icon md-icon"></span>
Keyboard & mouse
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../mouse/" class="md-nav__link">
<span class="md-ellipsis">
Mouse modes
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../mouse_jiggler/" class="md-nav__link">
<span class="md-ellipsis">
Mouse jiggler
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../pico_hid/" class="md-nav__link">
<span class="md-ellipsis">
Pico HID (USB, PS/2)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../bluetooth_hid/" class="md-nav__link">
<span class="md-ellipsis">
Bluetooth HID
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../msd/" class="md-nav__link">
<span class="md-ellipsis">
Mass Storage Drive
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../usb_ethernet/" class="md-nav__link">
<span class="md-ellipsis">
Ethernet-over-USB
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../usb_serial/" class="md-nav__link">
<span class="md-ellipsis">
Serial-over-USB
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../usb_dynamic/" class="md-nav__link">
<span class="md-ellipsis">
Dynamic USB configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../gpio/" class="md-nav__link">
<span class="md-ellipsis">
GPIO (pins, relays, lamps, etc)
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_5" >
<label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="">
<span class="md-ellipsis">
Advanced usage
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_5">
<span class="md-nav__icon md-icon"></span>
Advanced usage
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../on_boot_config/" class="md-nav__link">
<span class="md-ellipsis">
On-boot configuration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../vnc/" class="md-nav__link">
<span class="md-ellipsis">
Using VNC
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../multiport/" class="md-nav__link">
<span class="md-ellipsis">
Multiport KVM-over-IP
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../wol/" class="md-nav__link">
<span class="md-ellipsis">
Wake-on-LAN the server
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../ipmi/" class="md-nav__link">
<span class="md-ellipsis">
IPMI & Redfish integration
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../pst/" class="md-nav__link">
<span class="md-ellipsis">
Persistent storage
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../prometheus/" class="md-nav__link">
<span class="md-ellipsis">
Prometheus monitoring
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_6" >
<label class="md-nav__link" for="__nav_6" id="__nav_6_label" tabindex="">
<span class="md-ellipsis">
Development
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_6">
<span class="md-nav__icon md-icon"></span>
Development
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../api/" class="md-nav__link">
<span class="md-ellipsis">
HTTP API reference
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../building_os/" class="md-nav__link">
<span class="md-ellipsis">
Building PiKVM OS
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../3d_printing/" class="md-nav__link">
<span class="md-ellipsis">
Cases for 3D printing
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7" checked>
<label class="md-nav__link" for="__nav_7" id="__nav_7_label" tabindex="">
<span class="md-ellipsis">
Legacy
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_7_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_7">
<span class="md-nav__icon md-icon"></span>
Legacy
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
Arduino HID
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Arduino HID
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#serial-hid" class="md-nav__link">
<span class="md-ellipsis">
Serial HID
</span>
</a>
<nav class="md-nav" aria-label="Serial HID">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#usb-keyboard-and-mouse" class="md-nav__link">
<span class="md-ellipsis">
USB keyboard and mouse
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#ps2-keyboard" class="md-nav__link">
<span class="md-ellipsis">
PS/2 keyboard
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#spi-hid" class="md-nav__link">
<span class="md-ellipsis">
SPI HID
</span>
</a>
<nav class="md-nav" aria-label="SPI HID">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#parts-list" class="md-nav__link">
<span class="md-ellipsis">
Parts list
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#list-of-connections-to-be-made" class="md-nav__link">
<span class="md-ellipsis">
List of connections to be made
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#preparing-the-installation-for-spi-devices-and-programming" class="md-nav__link">
<span class="md-ellipsis">
Preparing the installation for SPI devices and programming
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#flashing-the-arduino" class="md-nav__link">
<span class="md-ellipsis">
Flashing the Arduino
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#enable-the-spi-configuration-and-restart-kvmd" class="md-nav__link">
<span class="md-ellipsis">
Enable the SPI configuration and restart kvmd
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#fixing-the-usb-absolute-mouse-on-windows-98" class="md-nav__link">
<span class="md-ellipsis">
Fixing the USB absolute mouse on Windows 98
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#serial-hid" class="md-nav__link">
<span class="md-ellipsis">
Serial HID
</span>
</a>
<nav class="md-nav" aria-label="Serial HID">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#usb-keyboard-and-mouse" class="md-nav__link">
<span class="md-ellipsis">
USB keyboard and mouse
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#ps2-keyboard" class="md-nav__link">
<span class="md-ellipsis">
PS/2 keyboard
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#spi-hid" class="md-nav__link">
<span class="md-ellipsis">
SPI HID
</span>
</a>
<nav class="md-nav" aria-label="SPI HID">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#parts-list" class="md-nav__link">
<span class="md-ellipsis">
Parts list
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#list-of-connections-to-be-made" class="md-nav__link">
<span class="md-ellipsis">
List of connections to be made
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#preparing-the-installation-for-spi-devices-and-programming" class="md-nav__link">
<span class="md-ellipsis">
Preparing the installation for SPI devices and programming
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#flashing-the-arduino" class="md-nav__link">
<span class="md-ellipsis">
Flashing the Arduino
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#enable-the-spi-configuration-and-restart-kvmd" class="md-nav__link">
<span class="md-ellipsis">
Enable the SPI configuration and restart kvmd
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#fixing-the-usb-absolute-mouse-on-windows-98" class="md-nav__link">
<span class="md-ellipsis">
Fixing the USB absolute mouse on Windows 98
</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1>Arduino HID</h1>
<div><div class="admonition warning">
<p class="admonition-title">Legacy warning</p>
<p>This page describes the legacy keyboard and mouse emulator used in old DIY builds.
There is no point using it today because there is a more modern and better replacement for the <a href="../pico_hid/">new Pico HID</a>.
This one can also serve as an in-place compatible replacement for the Arduino HID in the old build.</p>
</div>
<hr>
<h2 id="serial-hid">Serial HID<a class="headerlink" href="#serial-hid" title="Permanent link"></a></h2>
<div class="admonition warning">
<p class="admonition-title">PiKVM V3 note</p>
<p>Use <a href="#spi-hid">the SPI HID</a> for V3. Otherwise, you won't be able to use the Serial console.</p>
</div>
<h3 id="usb-keyboard-and-mouse">USB keyboard and mouse<a class="headerlink" href="#usb-keyboard-and-mouse" title="Permanent link"></a></h3>
<ol>
<li>
<details class="example">
<summary>Get some parts</summary>
<ul>
<li>Arduino Pro Micro (based on an ATMega32u4).</li>
<li><a href="https://www.sparkfun.com/products/12009">Logic level shifter</a>.</li>
<li>1x NPN transistor (almost any NPN transistor: 2n2222 or similar).</li>
<li>1x 390 Ohm resistor.</li>
<li>A breadboard and wires.</li>
</ul>
</details>
</li>
<li>
<details class="example">
<summary>Build the Arduino HID according to the scheme</summary>
<p><img src="arduino_serial_hid.jpg"></p>
</details>
</li>
<li>
<p>Power up PiKVM and switch it to RW-mode using command <code>rw</code>.</p>
</li>
<li>
<p>Add these lines to <code>/etc/kvmd/override.yaml</code>:</p>
<div class="highlight"><pre><span></span><code><span class="nt">kvmd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">hid</span><span class="p">:</span>
<span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">serial</span>
<span class="w"> </span><span class="nt">reset_pin</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">4</span>
<span class="w"> </span><span class="nt">device</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">/dev/kvmd-hid</span>
</code></pre></div>
</li>
<li>
<p>Create file <code>/etc/udev/rules.d/99-kvmd-extra.rules</code>:</p>
<div class="highlight"><pre><span></span><code>KERNEL=="ttyAMA0", SYMLINK+="kvmd-hid"
</code></pre></div>
</li>
<li>
<p>Run <code>systemctl disable getty@ttyAMA0.service</code>.</p>
</li>
<li>
<p>Remove <code>console=ttyAMA0,115200</code>or <code>console=serial0,115200</code> and <code>kgdboc=ttyAMA0,115200</code> or <code>kgdboc=serial0,115200</code> from <code>/boot/cmdline.txt</code>.</p>
</li>
<li>
<p><a href="../flashing_hid/">Flash the Arduino HID</a>.</p>
</li>
<li>
<p>Perform <code>reboot</code>.</p>
</li>
</ol>
<h3 id="ps2-keyboard">PS/2 keyboard<a class="headerlink" href="#ps2-keyboard" title="Permanent link"></a></h3>
<p>Using the PS/2 firmware currently have some limitations:</p>
<ul>
<li>The possibility of using the switchable USB HID is excluded.</li>
<li>PS/2 mouse is not supported right now (but it will).</li>
</ul>
<p>Both of these problems will be solved in the nearest future and the two different firmware versions will be combined into one universal one.</p>
<p>To select the PS/2 firmware, follow the instructions for the <a href="#usb-keyboard-and-mouse">USB</a>, but with one exception:</p>
<details class="note">
<summary>Before <code>make</code> you will need to edit file <code>platformio-avr.ini</code></summary>
<p>Open the file and find these lines:</p>
<div class="highlight"><pre><span></span><code><span class="k">[_common]</span>
<span class="na">build_flags</span><span class="w"> </span><span class="o">=</span>
<span class="w"> </span><span class="na">-DHID_PS2_KBD_CLOCK_PIN</span><span class="o">=</span><span class="s">7</span>
<span class="w"> </span><span class="na">-DHID_PS2_KBD_DATA_PIN</span><span class="o">=</span><span class="s">5</span>
<span class="w"> </span><span class="na">-DHID_USB_CHECK_ENDPOINT</span>
<span class="c1"># ----- The default config with dynamic switching -----</span>
<span class="w"> </span><span class="na">-DHID_DYNAMIC</span>
<span class="w"> </span><span class="na">-DHID_WITH_USB</span>
<span class="w"> </span><span class="na">-DHID_SET_USB_KBD</span>
<span class="w"> </span><span class="na">-DHID_SET_USB_MOUSE_ABS</span>
<span class="c1"># ----- PS2 keyboard only -----</span>
<span class="c1"># -DHID_WITH_PS2</span>
<span class="c1"># -DHID_SET_PS2_KBD</span>
<span class="c1"># ----- PS2 keyboard + USB absolute mouse -----</span>
<span class="c1"># -DHID_WITH_USB</span>
<span class="c1"># -DHID_WITH_PS2</span>
<span class="c1"># -DHID_SET_PS2_KBD</span>
<span class="c1"># -DHID_SET_USB_MOUSE_ABS</span>
<span class="c1"># ----- PS2 keyboard + USB relative mouse -----</span>
<span class="c1"># -DHID_WITH_USB</span>
<span class="c1"># -DHID_WITH_PS2</span>
<span class="c1"># -DHID_SET_PS2_KBD</span>
<span class="c1"># -DHID_SET_USB_MOUSE_REL</span>
</code></pre></div>
<p>By default, the firmware works with USB HID and supports dynamic mode switching. You can choose one of the other modes by commenting some lines and uncommenting others. This example to use a USB mouse and PS/2 keyboard:</p>
<div class="highlight"><pre><span></span><code><span class="na">...</span>
<span class="c1"># ----- The default config with dynamic switching -----</span>
<span class="c1"># -DHID_DYNAMIC</span>
<span class="c1"># -DHID_WITH_USB</span>
<span class="c1"># -DHID_SET_USB_KBD</span>
<span class="c1"># -DHID_SET_USB_MOUSE_ABS</span>
<span class="c1"># ----- PS2 keyboard only -----</span>
<span class="na">...</span>
<span class="c1"># ----- PS2 keyboard + USB absolute mouse -----</span>
<span class="w"> </span><span class="na">-DHID_WITH_USB</span>
<span class="w"> </span><span class="na">-DHID_WITH_PS2</span>
<span class="w"> </span><span class="na">-DHID_SET_PS2_KBD</span>
<span class="w"> </span><span class="na">-DHID_SET_USB_MOUSE_ABS</span>
<span class="c1"># ----- PS2 keyboard + USB relative mouse -----</span>
<span class="na">...</span>
</code></pre></div>
</details>
<p>Next, connect Arduino pins to the female PS/2 port of your motherboard. Choose the purple port. If your motherboard only have one port, it's probably universal and can be used either for the keyboard or for the mouse. Most likely, it is painted in two colors: green and purple. You can use it either.</p>
<details class="example">
<summary>Follow the diagram</summary>
<table>
<thead>
<tr>
<th>Female PS/2 port (front view)</th>
<th>Pinout</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="ps2_kbd.png" alt="drawing" width="200"></td>
<td>Arduino pin 7 &lt;-&gt; PS/2 CLOCK<br>Arduino pin 5 &lt;-&gt; PS/2 DATA<br>Arduino GND pin &lt;-&gt; PS/2 GND</td>
</tr>
</tbody>
</table>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Connect VIN pin of Arduino to <a href="https://pinout.xyz/pinout/5v_power">any Raspberry's 5v pin</a> for PS/2 only device. But you don't need to connect the Arduino VIN pin if you connected USB (Arduino will get power through it).</p>
</div>
</details>
<hr>
<h2 id="spi-hid">SPI HID<a class="headerlink" href="#spi-hid" title="Permanent link"></a></h2>
<p>Using an SPI connection, an Arduino Micro (not Pro) or compatible can be flashed from the Pi and used as an HID keyboard and mouse. Unlike UART, SPI does not share pins with Bluetooth on the Raspberry Pi so the Bluetooth radio does not need to be disabled.</p>
<p><img src="arduino_spi_hid.png" alt="Diagram of the Arduino SPI wiring for HID keyboard and mouse." width="654"></p>
<p>Before powering either device, double-check the connections. The following should be wired from the Pi to either the level shifter or the Arduino. While the Arduino tolerates 3.3V logic input, 5V outputs from the Arduino can damage or destroy the Raspberry Pi and must not be connected directly to 3.3V GPIO pins directly.</p>
<h3 id="parts-list">Parts list<a class="headerlink" href="#parts-list" title="Permanent link"></a></h3>
<p>There are very few parts needed besides the Raspberry Pi to build the solution. Some parts may be purchased with or without headers, if headers are not pre-soldered, it may be necessary to order some breakaway header strips and solder them to the boards prior to assembly unless the wires will be soldered directly to the boards.</p>
<ul>
<li>Raspberry Pi Zero W or Pi 4 are the most popular boards for this solution, pre-soldered headers recommended</li>
<li>Arduino Micro (or compatible) microcontroller board with pre-soldered headers recommended</li>
<li>Logic Level Converter. This may be RX/TX, Bidirectional, or Single Supply</li>
<li>1x PNP transistor (2n2907 or equivalent). Note this is different from the one suggested in the Serial HID docs above, that is an NPN while this is a PNP.</li>
<li>1x 390 ohm resistor</li>
<li>Dupont wires (female to male pin) recommended for breadboard or other suitable means of making the connections</li>
<li><em>Optional:</em> Breakaway headers for the logic level converter</li>
<li><em>Optional:</em> Breadboard large enough to accommodate the parts</li>
<li><em>Optional:</em> Header pins for connection to a breadboard</li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>A smaller "Pro Micro" board is available in a 3.3V model but the SS connection (RX_LED) is not available as a separate pin or solderable hole. If using this board, a jumper wire can be soldered to the resistor for the RX_LED but there is risk of burning the resistor, the LED, the board, or other components in the process. Advantages of this board include not requiring a logic level converter and reduced breadboard or board space for building the solution.</p>
</div>
<h3 id="list-of-connections-to-be-made">List of connections to be made<a class="headerlink" href="#list-of-connections-to-be-made" title="Permanent link"></a></h3>
<p>For the primary functionality, most connections are made using a 4-channel bidirectional level shifter</p>
<ul>
<li>Pi 3v3 to LV on the level shifter</li>
<li>Pi Ground to LV GND</li>
<li>Arduino GND to HV GND</li>
<li>GPIO10 (MOSI) via the level shifter to MOSI on the Arduino</li>
<li>GPIO9 (MISO) via the level shifter to MISO on the Arduino</li>
<li>GPIO11 (SPIO_SCLK) via the level shifter to SCK on the Arduino</li>
<li>GPIO7 (SPIO_CE1_N) via the level shifter to SS (or RX_LED) on the Arduino</li>
</ul>
<p>An additional circuit is used with a transistor to reset the HID for mode changes and for SPI programming as follows:</p>
<ul>
<li>GPIO25 to PNP base on transistor</li>
<li>PNP emitter to ground</li>
<li>PNP collector to RST on the Arduino</li>
</ul>
<p>Pictures of this setup are also available in full resolution for download to assist for both the Raspberry Pi and the Arduino board. A smaller version of the images has been included on this page and can be downloaded.</p>
<table>
<thead>
<tr>
<th>Raspberry Pi Closeup</th>
<th>Breadboard with Arduino</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="arduino_spi_hid_rpi.jpg" alt="A closeup of the Raspberry Pi wired to the breadboard." width="300"></td>
<td><img src="arduino_spi_hid_bb.jpg" alt="Arduino on a breadboard fully wired to the Pi." width="300"></td>
</tr>
</tbody>
</table>
<p>Programming assumes the Arduino is powered via USB, either from the connected host or the Pi itself. If the USB is not connected, 5 V may be provided by the Raspberry Pi GPIO but should be disconnected prior to connecting USB to the Arduino's USB port. The Raspberry Pi does not have backcurrent protection, a circuit using one or more Schottky diodes can be built to OR power from multiple sources but it's easier and more cost effective to avoid conflict and voltage differences between power supplies by leaving the 5 V wire disconnected.</p>
<h3 id="preparing-the-installation-for-spi-devices-and-programming">Preparing the installation for SPI devices and programming<a class="headerlink" href="#preparing-the-installation-for-spi-devices-and-programming" title="Permanent link"></a></h3>
<p>As of the latest package release, the kvmd service supports SPI. It should be sufficient to ensure the packages are up-to-date with the latest release, the programmer is installed, and the SPI device overlay is loaded at boot.</p>
<ul>
<li>Switch the filesystem to read-write mode with <code>rw</code></li>
<li>Add <code>dtoverlay=spi0-1cs</code> to <code>/boot/config.txt</code></li>
<li>Perform <code>reboot</code>.</li>
</ul>
<h3 id="flashing-the-arduino">Flashing the Arduino<a class="headerlink" href="#flashing-the-arduino" title="Permanent link"></a></h3>
<p>Instructions on flashing the Arduino can be found on the page <a href="../flashing_hid/">Flash the Arduino HID</a>.</p>
<p>If programming fails, ensure the Arduino is powered and check the wiring again. If there is a misconfiguration, power off the Pi and the Arduino, correct the wiring, and try again. Note it is not recommended or required to supply 5V power from the Raspberry Pi if the Arduino is USB powered, if the issue appears to be power related it may be removed from the solution and replaced with a powered USB connection if it will aid in troubleshooting but check all other wires first to ensure there are no shorts.</p>
<p>After you have double and triple-checked your wiring (in particular make sure the pins you are using on the Pi are correct, the documentation uses the GPIO pin labels, NOT the sequential pin numbers from 1-40. A good pinout reference is <a href="https://pinout.xyz/#">@Gadgetoid's version</a>, you might try flashing the Arduino by holding down the RESET button on the chip while running <code>make install</code>. If this works, then at least you know your SPI wiring is correct.</p>
<p>Wiring problems are a common issue but there could be other reasons for programming not to complete. While it is not possible to list every possible problem and solution here, there is an active user community in our <a href="https://discord.gg/bpmXfz5">Discord</a> with others familiar with the solution and willing to help.</p>
<h3 id="enable-the-spi-configuration-and-restart-kvmd">Enable the SPI configuration and restart kvmd<a class="headerlink" href="#enable-the-spi-configuration-and-restart-kvmd" title="Permanent link"></a></h3>
<p>Once the installation has completed, all that should remain is to add the following configuration to <code>/etc/kvmd/override.yaml</code> and restart the kvmd service. If the first line exists due to existing overrides, omit that line and either add or update the hid section as appropriate.</p>
<div class="highlight"><pre><span></span><code><span class="nt">kvmd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">hid</span><span class="p">:</span>
<span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">spi</span>
<span class="w"> </span><span class="nt">chip</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">0</span>
<span class="w"> </span><span class="nt">bus</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">0</span>
<span class="w"> </span><span class="nt">sw_cs_pin</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">7</span>
<span class="w"> </span><span class="nt">reset_pin</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">25</span>
<span class="w"> </span><span class="nt">reset_inverted</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
</code></pre></div>
<p>After saving the changes to <code>/etc/kvmd/override.yaml</code>, restart <code>kvmd</code> and clear your browser cache. The command to restart <code>kvmd</code> is</p>
<div class="highlight"><pre><span></span><code># systemctl restart kvmd
</code></pre></div>
<p>If your device is still in read-write mode, <code>ro</code> will put the SD back in read-only mode.</p>
<hr>
<h2 id="fixing-the-usb-absolute-mouse-on-windows-98">Fixing the USB absolute mouse on Windows 98<a class="headerlink" href="#fixing-the-usb-absolute-mouse-on-windows-98" title="Permanent link"></a></h2>
<p>Due to an ancient buggy driver, the USB absolute mouse on Windows 98 moves only within the upper-left quarter of the screen. To fix this, just recompile the firmware with uncommented flag <code>-DHID_WITH_USB_WIN98</code> in <code>platformio-avr.ini</code>.</p></div>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
<button type="button" class="md-top md-icon" data-md-component="top" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12Z"/></svg>
Back to top
</button>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
<div class="md-copyright__highlight">
Copyright &copy; 2018-2022 Maxim Devaev
</div>
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "..", "features": ["navigation.indexes", "navigation.sections", "navigation.top", "navigation.tracking", "navigation.expand", "search.highlight", "search.share", "search.suggest"], "search": "../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script src="../assets/javascripts/bundle.dd8806f2.min.js"></script>
</body>
</html>