I have a Raspberry Pi set up as NAS. The storage is an external HDD powered through USB. I would like to encase this whole thing in some nice box and still be able to easily use the HDD, without disassembling the whole thing.

My idea is the following:

USB toggle switch diagram

USB A would be connected to the external HDD and USB B would be just a USB extension cord accessible from the outside. The box with question marks would be a toggle switch controllable through a GPIO header.

My idea how to wire the whole thing in the easiest way is sketched in the following diagram (the switches represent USBs):


simulate this circuit – Schematic created using CircuitLab

I'm not sure if it's okay to just switch the power rail between the two outlets.

So far I have the following ideas how to implement it:

  • design transistor flip-flop toggle switch
  • use analog switch, something like CMOS-4066
  • use dedicated circuit like MAX1562 (this one is switch only, though)

Is my idea sensible? Do you know any ready-made solution? Do you know how to solve this?

  • 2
    \$\begingroup\$ In what way is this a better idea than using a hub? \$\endgroup\$ Commented Mar 28, 2014 at 23:08
  • 1
    \$\begingroup\$ Are you saying that you want to disconnect the HDD from the RPi so that some other host can acccess the HDD directly? Sort of an "inverse hub"? \$\endgroup\$
    – Dave Tweed
    Commented Mar 28, 2014 at 23:22
  • \$\begingroup\$ Does "(the switches represent USBs):" mean that the DPDT switches marked USB A, USB B, and USB C are really the USB connectors on your proposed unit? If so, please remove them from your drawing - they are horribly misleading to anyone who can read a schematic. Wires with the USB signal names, and a "USB Conn A" label would be much clearer. \$\endgroup\$ Commented Mar 29, 2014 at 0:05
  • 2
    \$\begingroup\$ USB A-B Switches do exist, even commercially. Have you thought of using one of those? \$\endgroup\$
    – Passerby
    Commented Mar 29, 2014 at 1:32
  • \$\begingroup\$ @IgnacioVazquez-Abrams this works other way around. One HDD, two computers. DaveTweed yes PeterBennett fixed Passerby they are generally only manual and quite expensive. \$\endgroup\$
    – jnovacho
    Commented Mar 29, 2014 at 9:25

2 Answers 2


You do not want to try running the USB signals through a mechanical switch. Too much loss of signal integrity.

Do not attempt to switch the USB signals with a '4066 type chip. USB 2.0 runs at 480MHz when in high speed mode and the cheap mux chip will severely attenuate the signalling.

You need to manage the USB Power separate from the USB D+/D- lines. A drive operating off the USB port could be pulling up to 500 mA and that takes a circuit specifically designed for that current level to manage it's switching.

I have built USB selection devices in the past using special circuitry on a board I designed. The USB data signals were switched via a Fairchild FSUSB30MUX part. The power to the target device was managed through a MIC2026-1YM USB power switch device.

The picture below shows the general layout of the circuit. In this example of equipment this device had a USB Type B jack that would mate with one computer and then a USB Type A jack that would go to the shared external USB Drive or USB Stick. The other side of the USB signal MUX came from the output of a 4 port USB Hub. The input side of that USB Hub came from another USB Type B jack that would come from another computer.

enter image description here

Related information in this other answer.


At work, some years ago, we built a device to switch an USB key drive from one computer to another. We used four DPST reed relays, although it's not a standard way to work with USB, it worked like a charm. However, some rules must be followed:

  • You have to handle all four power and signal lines
  • Don't switch the lines: just disconnect/reconnect them from the bus. To disconnect, fist disconnect the data lines then the power lines. To reconnect, connect first the power then the data lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.