Using USB for power

Thread Starter

richard_h

Joined Jul 2, 2010
4
Hi all,
I'm building a very simple project - a desklamp consisting of 9 LEDs. They draw up to 20mA each at 3.2V, so that's 180mA total.

I was planning to power this off 5V from USB, so use a 100Ω resistor on each one to drop the 1.8V, giving me 18mA, or 162mA total.

Then, having chopped the end off a USB cable, I started having second thoughts.

1) Do I need to talk to the computer to negotiate how much power I want to draw?

2) If not, do I still need to terminate the data lines somehow to keep it happy?

3) If I got keen later and used a microcontroller or something to PWM the LEDs, will the USB port be happy with the interrupted current draw, or do I need a capacitor to smooth it out? And then do I need to prevent the capacitor feeding back into the port when the computer is turned off?

Any tips most welcome.
Richard
 

LDC3

Joined Apr 27, 2013
924
You could probably make the lamp as you originally planned if you plugged it into a powered USB hub. I believe the powered hubs have more than enough power for all the attachments. The USB hub on the computer limits the current (I think it is below 50mA) until you negotiate for more (but you may not always get it).
 

Thread Starter

richard_h

Joined Jul 2, 2010
4
A useful option, thanks. I think I'd rather not rely on user behaviour, though, even if the most likely user for the foreseeable future is me :)

Richard
 

wayneh

Joined Sep 9, 2010
17,498
1) Do I need to talk to the computer to negotiate how much power I want to draw?
At that current level, I don't think so. Just be careful about how many other things share the same USB power source.

2) If not, do I still need to terminate the data lines somehow to keep it happy?
Nope, just leave them disconnected in such a way that there in no risk of short.
3) If I got keen later and used a microcontroller or something to PWM the LEDs, will the USB port be happy with the interrupted current draw, or do I need a capacitor to smooth it out? And then do I need to prevent the capacitor feeding back into the port when the computer is turned off?
While I suspect this would be fine, I'd probably be nervous about doing it to my beloved laptop. So yes, I think I'd look to smooth out the load.

I think USB is already designed to handle reverse current but a blocking diode would eliminate any question. A diode would further drop voltage a bit, about 0.7V. If you incorporate this from the beginning, you can just use smaller resistors to compensate.
 

BobTPH

Joined Jun 5, 2013
8,967
Without communicating with the host, you are only allowed to draw 100mA from a USB port.

This only applies to actual USB data ports. A USB charger will typically supply 500mA or more without any action from the consumer.

Bob
 
Last edited:
Top