Electronic – arduino – how to cut off power from usb device using arduino

arduinomosfetswitchesusb

Seems like I can't restart USB modem in Linux, so I setup an arduino gig to emulate usb modem plug/unplug.

I have Arduino Uno R3 and several N-channel mosfet https://www.sparkfun.com/products/10213, and used the setup in http://bildr.org/2012/03/rfp30n06le-arduino/ for switching the ground wire of the usb modem on/off.

This works, for a while, then the usb hub started to have problem. I think I have to really emulate USB plug/unplug, that is, cutting off both the power wire and the data wire of the usb modem.

The problem is, while the USB power has +5V and ground, the data has D+ ~+2.5V and D- ~-2.5V, they doesn't have a common ground, to be used with the setup using N-channel mosfet.

What should I do? if I buy another arduino uno just for the data wire, I still have problem, the data ground is not the same with the arduino ground (I think N-Mosfet requires a common ground), I don't know if this will cause problem.

Do I need a DC voltage step-up component? or is there other solution.

I'm thinking how usb plug works, is first connect the power wire, wait some micro seconds then connect the data wire, with unplug the opposite.

Best Answer

switching the ground wire of the usb modem on/off.

Bad choice. Use a P-channel MOSFET (like IRLML6401) to switch the +5 Volt wire instead.

Cutting GND could make the data lines float near the 5 Volts power level, because there is usually some ESD protection on them. There may also be some return current on them. Both would cause malfunctions in USB hubs.

how usb plug works, is first connect the power wire, wait some micro seconds

The reason behind this is to reduce the chance of ESD damage in the data lines - the power lines are much less likely damaged by ESD. You don't need to separate the data lines (and GND) at all if you just cut the power on the 5 volt line.