Share a USB Keyboard and Mouse between two PCs (USB Hosts)

Both at the lab and at home I have, at any give time, a desktop PC and another computer (laptop or a single computer board like Raspberry pi) connect. Many times I have the need to share peripherals between them. Typically the following peripherals are shared: 1) Monitor/Display; 2) Keyboard; 3) Mouse.

 


The "sharing" of these peripherals (until now) was the disconnecting by-hand from one host (e.g., desktop PC) to connect in another (e.g., laptop PC). For example unplugging the USB cable of the keyboard from the desktop and plug it to the laptop or Raspberry Pi. During a work session this "switching" happens several times. This becomes a nuisance rather quickly.

The Monitor is not an issue for me as it has two inputs so I can have two PCs connected to it and easily switch between them by pressing a button. Wouldn't be nice if I had a similar functionality for the keyboard and mouse... the challenge was set: I had to setup "something" that allowed me to switch both the keyboard and mouse between USB host just by pressing a button.

The solution found is based in a USB Upstream Switcher ( Yepkit YKUP board) that switches a USB device between two USB hosts. By hooking-up together two YKUP boards I'm able to switch both the keyboard and mouse between my laptop and desktop PC as shown in the following image.



On my setup the keyboard and mouse are connected by default, through two YKUP boards, to the desktop PC. When I need to switch them to the laptop PC (or Raspberry Pi) I press the push-button (see image below). If I press the push-button again keyboard and mouse will be switched back again to the desktop PC.



Let's see in detail the several components and how to set-it-up. I used the following parts/components:




The solution diagram is the following.


Next a walk-through the system assembly and first use.

I started by cutting the copper wire cable to size considering the final location of both the YKUP boards and push-button. I choose to place the YKUP boards in a slot underneath my desk, so I will need approximately 1m of cable.
The push-button, to trigger the switching, I want it in the monitor base so that when I push the monitor button to switch between PCs I will immediately after push the push-button to switch the USB devices.



I did not have a support for the CR2032 battery so improvisation was in order. My solution was to use a plastic coated paper clip like shown bellow.


Then connect the wires.


The complete wire/battery/push-button assembly looks like the following.



Notice that I soldered the wires to the push-button terminal. Now the wire connected to the negative pole (-) of the battery must be connected to GND pin of the YKUP boards "EXT CTRL", and the wire coming from the push-button must connect to the SIG pin of the YKUP boards "EXT CTRL".

Because I want to switch both the keyboard and mouse (so both the YKUP boards) simultaneously with a single button push, the "EXT CTRL" pins of both YKUP boards should be tied together. This is made easy by stacking the YKUP boards like shown bellow.



By stacking the two YKUP boards like shown also makes them share the power, so to power both boards I just have to connect the external 5V power to one of them (I'm powering from one of the desktop USB ports using a Micro USB cable). The picture bellow show in detail how the board-to-board connectors are assembled in each board.



Now the final step is to connect all of the USB cables. In my setup the Upstream 1 port of each YKUP connects to the desktop PC and the Upstream 2 port of each YKUP connects to the laptop PC. Then the mouse is connected to the downstream of a YKUP and the keyboard is connected to the downstream of the other YKUP.

Let's test it.



Works like a charm!



Comentários