Tuesday, 31 March 2020

Simple USB KVM adapter

With the shadow of Covid-19 hanging over our heads, I, like many others, am now working from home.

Having my home PC set up right next to my work set up has been a bit of a pain - two keyboards and two mice competing for desk space. Plus the work keyboard and mouse was a spare wireless set I had kicking about - not really comfortable enough for long-term use.

The monitor I attached to my work laptop was the second monitor I use for my home set-up - thankfully it has two inputs, so that's an easy one-button switch.

I wanted to use my main keyboard and mouse with my work set-up as well as home, but didn't want to unplug/replug each time.

I also wasn't too keen or just ordering a USB KVM adapter (a device which lets multiple computers share keyboard, mouse and monitor), as recently some of our local postal and delivery works have fallen ill, and so I'm avoiding any non-essential deliveries - I don't like the idea of putting others at risk for stuff that's a 'nice-to-have'.

So I figured I'd look through the electronics pile and see what I could piece together.

I did have a PS/2 KVM that I was hoping to adapt, but having read the datasheet for the bus IC that underpins it, it had a low maximum current rating - it might have been fine for just a keyboard or a mouse, but the keyboard I want to use has a backlight, audio controller and USB hub built in, and a brief look with

lsusb -v

showed that they would easily surpass that maximum rating.

Software options are also a no go - whilst they'd been fine when working locally, they won't work with my work's VPN, the the IT guys have enough on their plate without me adding to it.


So, I ended up going for the simplest of options. I had some relays - they were obviously meant for higher power application than this, but found that wired up in parallel, 5V was enough to trigger them. I was planning on powering it from a USB port, so 5V was the target.

A rough schematic of the switch


Unfortunately they had a weird footprint that put one of the pins in between rows on standard perfboard, so I ended up dead-bug soldering them.
A diode across each of them to prevent voltage spikes from the coils, some USB extension leads and a switch later, and I had a 4 channel switch.

I was a bit concerned at the lack of a protective load on this circuit, but adding any additional resistance from the power to the relays would prevent them from switching - as they're really designed for higher power applications, I reason that the coils have enough power requirement to prevent a short.

I have ran it for a few days under close observation and seen no temperature / magic smoke issues, and it's only ever powered when I'm sat right in front of it, so it should be fine. Obviously if this wasn't a "whatever's at hand" project, there'd be much more elegant ways of doing this (bus IC, 4 pole switch, more appropriate relays, etc), but here we are.

A gratuitous amount of cable ties, double sided tape and an old business card box provides structure and an enclosure. I'll probably tidy it up a bit more later as time allows, but for now it's enough that it works.