# Powering a device by USB?

I would like to power a device via the 5V USB port on a computer, because I will also be communicating with the computer via the USB data cables.

I know that USB ports provide 5V, but from what I've read here.

USB 1.0, 2.0, and 3.0 all give variable amperage outputs. The device is supposed to negotiate with to computer to ask for more amperage, and the default is set at 100 mA.

I would like my circuit to run on 10 mA. I understand the relationship between amperage and voltage. (I.E. Ohm's Law)

Using: $$R = \frac{5V}{0.01A} = 500\Omega.$$

Perhaps I'm having difficulty understanding the concept, but does this mean I will receive 10 mA regardless of how much is flowing out of the USB port?

• 100 mA is a maximum provided current, if your device needs 10 mA, it won't drain more just because it is possible. May 4, 2015 at 8:54
• I think what I'm having a hard time understanding is Ohm's Law in regard to pulling current. If a power supply CAN offer a certain amount of amperage, why doesn't it? How would the USB power supply "know" to send 10 mA instead of just dumping the 100 mA on my device? May 4, 2015 at 8:57
• You need to invert your thinking. Your device draws (pulls) current, the supply does not push it. May 4, 2015 at 9:11
• It is more like your device takes the 10mA current rather than the USB power supply sends it. May 4, 2015 at 9:12
• USB (2.0, for example) spec is such that up to 100mA can be drawn from a USB peripheral without first going through the (very complicated) negotiation process. Once you do, up to 500mA. USB hosts can (and often will, tho this is perhaps one of the less stringently observed parts of the USB spec) measure the current drawn by a peripheral, and if you draw more, shut you down (cut off power) because you're operating outside the spec. Most USB peripherals would draw current in elaborate circuitry, but even a simple resistor: R=V/I=5/0.1=50ohms across Vbus & Gnd wires before you risk shut-down. May 4, 2015 at 9:13

The power supply doesn't always output its maximum current (unless needed), instead it outputs a particular voltage (in your case 5v) and the load presented by the device determines how much current will be drawn. If there is nothing connected to the output, the current will be zero.

However if the load attempts to draw too much current (i.e. more than 100 mA for a USB port that is rated for only 100 mA), then depending on the power supply, the voltage may sink below 5v, or the supply may stop working altogether due to a over-current shut-down mechanism.

As you stated, the current is determined ohms law, i.e. the voltage divided by the equivalent resistance of the load. As you already calculated, for a 10 mA current, the equivalent resistance of your load is 500 Ω. So if you replaced your device by a 500 Ω resistor, it would draw 10 mA. Obviously your device is much more complicated than a simple resistor, but that's what it looks like to the power supply.

In many cases, the load will not be a fixed amount. A trivial case is two LED's, each drawing 20 mA. One is on steady, and the other is blinking on and off. So the load varies between 20 mA and 40 mA. The supply will automatically adjust for this varying current.

• So, after selecting my components, I would view the datasheets to see exactly how much amperage they're drawing. As long as I'm within the range it really doesn't matter what amperage I'm running the circuit on. I just need to worry about supplying my components with the correct voltage"? May 4, 2015 at 9:22
• @Allenph Correct, you only need to worry about two things: that your circuit will operate correctly at the given voltage, in this case 5v; and second that your circuit doesn't draw more than the non-negotiated current limit which is 100 mA. In the latter case, you want to allow quite a bit of margin, i.e. it would be a good idea that the maximum current your circuit draws stayed below 80 mA or so. That's just good engineering practice. May 4, 2015 at 9:33
• Also good practice (if possible) to add a bit of decoupling and filtering at your end to make sure you are getting smooth supply. USB power can be a bit noisy. May 4, 2015 at 12:02
• @tcrosley can I view a computer's USB port as a CV source of 5V within the rated current (100mA), and once the load increase enough then the USB switches to a CC source of 100mA?
– KMC
May 19, 2021 at 5:01

I think what I'm having a hard time understanding is Ohm's Law in regard to pulling current. If a power supply CAN offer a certain amount of amperage, why doesn't it?

Think of a garden hose attached to your garden spigot. Let's say 1 gal/min flows out. Now partially block the hose with your thumb. That might reduce the flow to 0.5 gal/min. Your spigot is capable of supplying 1 gal/min but the hose is now only able to deliver less. Squeeze tighter and the flow decreases further.

Current behaves a lot like flow; voltage is a lot like pressure. Your spigot is roughly a constant pressure (constant voltage) supply and can only push as much flow (current) as can flow through the load - your thumb or the circuit.

If the city turns up the water pressure while you're doing this test, the flow past your thumb will increase. The same thing happens electrically if you increase the voltage and this is what Ohm's law is about.

You may be thinking about power supplies as if they were constant current supplies. There are such nthings but most are not. Constant current supplies are special purpose supplies that work by sensing the current they are supplying and actively adjusting their voltage as necessary to keep that current at the set value. A battery, your wall outlet, or a USB port power supply are more typical of constant voltage supplies. (I'm waffling about the constant voltage part because simple power supplies don't actively maintain their output voltage; as they supply more current their voltage decreases. Usually only sightly as they supply low currents, but more, as they approach their maximum capability.)

Update: doesn't that mean there is no constant? Yes, literally speaking. But a simple power supply such as a battery behaves more like a constant voltage power supply than it does like a constant current one, if the current draw is within its capability. And don't take "constant" too literally. A 5v USB supply might be a couple tenths above 5v with no load and drop a few tenths for typical loads, more for loads that draw more current, and in some cases, like my iMac's USB ports, may go to zero - disconnect - to protect themselves and the computer, if the load tries to draw too much current.

• Between both your answers I understand the concept...but your last tidbit completely threw me off...if simple power supplies aren't actively regulating their voltage...doesn't that mean there is no constant? Neither amperage nor voltage would be regulated... May 4, 2015 at 13:57
• He's taking about unregulated power supplies. Older, transformer based supplies with no regulating circuitry. May 4, 2015 at 14:18
• @Allenph: Regulation is never perfect, a real-world supply specified for a particular output voltage (so we aren't considering current-limited supplies at all) typically is modeled by a constant-voltage circuit element in series with a resistor (and inductor, if the output impedance is complex). You'll see this for supplies, amplifiers, etc. May 4, 2015 at 14:28

The only thing I want to add to the questions above is a clarification on Ohm's law. It isn't a law. It's an empirical relationship that many materials obey and it has some basis in statistical mechanics. However:

• Many "linear" resistors aren't linear (i.e. the filament of a light-bulb)
• Many materials don't follow Ohm's law (i.e. the gas inside a gas tube)

An ohmic resistor, therefore, is a resistor that behaves linearly within the operating range

• A clarification to your clarification: Ohm's Law is a law. In Science a Law is a theory that provides quantitative results within a domain of applicability. Checking the web I see other definitions like: "Laws differ from scientific theories in that they do not posit a mechanism or explanation of phenomena: they are merely distillations of the results of repeated observation." from en.wikipedia.org/wiki/Scientific_law In short Ohm's Law is a scientific law, not a legal law.
– Jim
May 4, 2015 at 23:59
• @Jim Maxwell's equations are mere equations, but Ohm's equation is law? Seems awkward. I agree that science has no laws, only theories. But why refer to theories as laws then? And if we must use the word "law" there are some theories (conservation of momentum, 2nd law of thermo, ect) that merit the title (we've never seem them break down) whilst Ohm's law, Hook's law are really dirty Taylor fits that break down easily! I'm not arguing to rename Ohm's law. I just think a lot of misunderstanding could be avoided if we pointed out more often that Ohm's law isn't.
– user11852
May 5, 2015 at 14:54
• Yes, the problem is that people think a "law" is somehow more profound than a "theory". In science this is not the case, laws are often weaker explanations than theories.
– Jim
May 5, 2015 at 20:26