I would like to get my Raspberry Pi (or some other single board computer) to act as a USB hub.

So if I plug it into a (main)computer I would like to be able to have the Raspberry Pi appear to be a USB hub to the main computer, and then have the Raspberry Pi USB ports be available to the (main)computer, and be able to emulate USB devices on the Raspberry Pi. Is this possible?

Can anyone suggest what software libraries/code I should be looking into to figure out how to do this?

Or can anyone suggest a Raspberry Pi OTG hat or a different board if there is a different board that would be better for doing this with?

  • 1
    Look into boards like Orange Pi which have both an OTG port and regular USB ports which can work at the same time. Commented Jan 22, 2019 at 12:57

1 Answer 1


In order for the Raspberry Pi to be recognised as a USB peripheral (which a hub is) by another computer, it would have to act as an USB slave. The Raspberry Pi B can only act as a USB host, so you'd have to use a Raspberry Pi Zero or A for acting as a USB slave.

However, the real problem is that the Raspberry Pi can only act as either a USB slave or a USB host at a time. Now, for your application, you'd need it to act as a USB host to the USB peripherals attached to the Pi and as a USB slave to the computer.

This means that forwarding the RPi's USB ports will never work. What would work is emulate different USB devices on a RPi 0 or A. This can be accomplished by setting the Pi to USB gadget mode. I suggest you Google that term if you're interested in that solution.

I'm afraid I don't know whether what you want is possible with a different SBC. You'll have to look for boards that have two separate USB host chips / root hubs (one for the slave side and one for the master). Arguably, you could add one via GPIO, eg via SPI, though that would likely be a lot of work to integrate on the software side.

If you don't need the Pi to work exactly like a hub, you could forward USB devices over the network. For that, you'd have to make sure Pi and computer are on the same network and install some software on both devices. It seems like a software called VirtualHere (commercial) could be used here.

Update: In the meantime, the Raspberry Pi 4B was released. It is the first Pi to actually include two USB host chips: A new USB 3.0 hub was added via PCIe, but the existing USB 2.0 OTG functionality was kept and routed to the USB-C connector normally used just for providing power. This means it could now actually be used in the way you imagined.

  • 3
    There's no problem from software perspective: you can have as many USB controllers as you like. There's even a driver to redirect USB traffic from one controller to the other, called g_zero. RPi Zero has only 1 USB controller though. Commented Jan 22, 2019 at 12:51
  • @DmitryGrigoryev That's good to know, thanks! I modified my answer a bit.
    – FD_
    Commented Jan 22, 2019 at 14:16

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.