Is it possible to program some chip that can switch between USB host and slave mode over an single micro USB cable talking to an Android device?

It would be OK if there was a slight pause between the switch if we have to reconfigure the chip to reconnect to the Android.

I don't need to be connected in both modes at the same time.


I have a Android device that supports USB file transfer mode so I can pull files from my GNU/Linux laptop, so you connected to it from the PC where the android device is in slave mode. And you can attach to it with an OTG cable and the device is in master mode so I can attach a external keyboard. I can switch between it by pulling out the cable and switching between them.

Even better would be to able to have both master and slave connected at the same time via the same cable. Ideally I could connect to a RasPI or some other programmable micro controller like Arduino. But I am not sure exactly.

Possible Solution

I found this note that uses a FTDI Vinculum II controller https://www.ftdichip.com/Support/Documents/AppNotes/AN_323_VNC2_Host_to_Android_Open_Accessory_and_FT232.pdf but I don't understand it all yet. Does this look like a possible solution?

Any simple devices like rasberry pi that could be used?

  • 3
    \$\begingroup\$ Most devices which can function in either role do the switching ultimately under software control (even if the software normally looks at an ID pin). But it is not clear how that will help you, and you can only be in one role on a given interface at a time. \$\endgroup\$ Feb 24, 2019 at 8:24
  • \$\begingroup\$ Thanks @ChrisStratton . That would be fine for my needs. So I am wondering what the best device would be to do that? Rasberry PI, Arduino, etc , and dev board that would be easy to use? \$\endgroup\$ Feb 24, 2019 at 8:56
  • \$\begingroup\$ host/slave is moderated by the on-the-go pin, \$\endgroup\$ Feb 24, 2019 at 9:12
  • \$\begingroup\$ Using a bluetooth keyboard would elimitate one cable connection. Seems a lot simpler... \$\endgroup\$
    – Turbo J
    Feb 24, 2019 at 10:24
  • \$\begingroup\$ @TurboJ yes, except for my case that is not possible but it is a good idea. \$\endgroup\$ Feb 24, 2019 at 11:14

1 Answer 1


Just like the chip in your phone, many (if not even most) of microcontrollers with USB interface can be programmed to be a host or a device, and could hypothetically even switch these roles. Exactly as your phone does!

A USB bus can't have multiple masters, so the "optional" goal of letting the phone be device to a PC and host to a keyboard is impossible to achieve on the same bus.

You really just want a bus switch compatible with USB signalling levels and speeds.

Since USB is such a large market, these things are produced by many IC manufacturers, for example Texas Instruments has a whole range of USB2 and USB3 switches; take the TS3USB30E as an example of a USB2 switch. Octopart tells me it can be had for little more than 1€.

functional diagram

So, you'd just wire up your connector going to your phone to the D+ / D- lines, the one going to your PC to the D1+ and D1- lines, and the one going to your keyboard to the D2+ / D2- lines.

To let the phone know that it's supposed to be in host mode, you will have to pull down its "ID pin" to ground (that's the fifth pin in a micro-USB connector). You can do that by means of yet another simple analog make-or-break switch (example).

  • \$\begingroup\$ Thank you, I have accepted this answer and will run with it. \$\endgroup\$ Feb 24, 2019 at 11:15
  • \$\begingroup\$ und vielen herzlichen Dank nochmals! \$\endgroup\$ Feb 24, 2019 at 20:54

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.