Electronic – How to light an LED to indicate when a usb port has a plug in it

ledusb

I'm looking for a way to light a 3.0v-3.4v 20mA LED to indicate when a usb 2.0 port has a plug in it. The light should only be on when a device is plugged in. My usb 5v line is about 3.2 to 3.3 amps with an Xbox 360 Controller connected. I tried wiring the led and resistor in series with the 5v usb port. The LED lit but the plugged in device did not work. I'm guessing the LED was only allowing 20mA to the device (Xbox 360 Controller) which was not enough for it.Would something like this work with a separate led power source? I'm REALLY new at this.
.

Best Answer

The first thing to realize is that you have misapplied your ammeter. You must insert such in series with a circuit by first breaking it, never in parallel. Were USB ports not typically current limited, in shorting VBus to ground through your meter, you would have blown your meter or its protection fuse or the host device's main board.

Next, realistically, it will be hard to detect this by electrical means except in software on the USB host chip. Devices with functional USB peripheral interfaces (ie, not, mini-drone battery chargers) have a pullup resistor on the D+ or D- line, however detecting that with circuitry not intimately cooperating with the USB host controller will be tricky. Were you able to modify the software on the host controller, it would be easy - the information is already obtained while getting ready to enumerate the peripheral, and it would be trivial to drive some available output to light an LED as a result.

One possible electrical option would be to insert a very small shunt resistance in the USB VBus line, and monitor the voltage drop across this with an op-amp. It is conceivably possible that an existing PTC resettable fuse could even function as the sense resistor, since even when cold it probably has a small resistance, but this will vary a lot with rating, and may be only a fraction of an ohm. That would mean you would need a well designed and carefully connected circuit to sense a low-current peripheral.

But for a DIY graft-on minimally modifying the existing circuitry, I think your best bet might be optical or conceivably mechanical. Perhaps you can rig an IR LED and phototransistor looking through the existing cutouts in the USB socket to detect beam blockage resulting when a plug is inserted.