26

I've just chopped a usb to micro-b usb cable.

There are 4 small wires inside

  • Red
  • Black
  • White
  • Green

Isn't it universal that Red is power and black is ground?

stevenvh
  • 145,145
  • 21
  • 455
  • 667
Jason94
  • 727
  • 2
  • 7
  • 16
  • 1
    *Very probably* but see [this question](http://electronics.stackexchange.com/questions/36317/standard-wire-colors) – MikeJ-UK Aug 02 '12 at 14:49
  • It was in the cable I chopped a while ago, but you should use a meter to verify. – jippie Aug 02 '12 at 15:07
  • 19
    It is, except when it isn't. –  Aug 02 '12 at 15:38
  • I realize this question is all but done, but anecdotally I had a power brick that I cut the end off of to repurpose elsewhere. The original plug was tip-negative, and had a tinned shield surrounding a blue wire. The shield was positive. Boy was that a surprise after the smoke ... – Bryan Boettcher Jul 16 '13 at 21:00
  • 1
    Beware, in 120/240v house wiring in North America, those exact four colors have totally different meanings: Green is safety ground, white is neutral/return and Red and Black are both "hot". – Harper - Reinstate Monica Feb 15 '16 at 22:30

5 Answers5

42

red = +5 V
white = D-
green = D+
black = ground

enter image description here

(Page 89 of the USB 2 specification)

edit (after reading the other 649 pages)
OK, that's from the formal specification. Reassuring, isn't it? It can even get you an accepted answer. You can feel it coming: there's a but.

enter image description here

This is from page 94. At first sight it seems to confirm what I said, but then there's that word "typical". So not mandatory? I read some more, and the answer isn't clear. The word "typical" must be the most used word in the spec, and also seems to be used for mandatory specifications:

enter image description here

There's that word again, page 93. Sounds like non-binding, but the text above it does say "should be oriented to allow" (emphasis mine). So "typical" seems to be used for mandatory specifications. Talk about confusion!

Apparently there's only 1 way you can trust: measure it. Compare the wire color with the pin number on the connector. The pin number locations are shown in the drawing and their assignments in the table. I'm 99 % sure that it will agree with the "typical" wiring assignment.

There's just that other 1 %... :-(


Further reading
USB version 2.0 specification (.zip file format, size 19.5 MB)

stevenvh
  • 145,145
  • 21
  • 455
  • 667
  • 5
    I have had USB cables from china where black was Vcc, and Red was Gnd. It blew up a test board. I was NOT happy. – Connor Wolf Jun 13 '15 at 18:59
  • 2
    I'm not sure if the same holds for electronics specs, but in Internet protocol specs the strongest wording for absolute mandatory requirements is "must", with "should" at the next lowest rung. Then again, in the illustration "Typical USB Plug" may mean just that: the image shows an example of type. Not all USB plugs will be identical. ...The "typical" wiring assignments in the table, though, I agree that's a lot less confidence-inspiring. – FeRD Sep 17 '16 at 12:50
7

It is a good bet, but I would not wage my life on it.

Wouter van Ooijen
  • 48,407
  • 1
  • 63
  • 136
  • 4
    Compliant USB ports also limit the current, and I especially wouldn't bet my life on that! – gbarry Aug 02 '12 at 14:49
  • 1
    IIRC the phrase in the standard is "limit the current to a safe value". That is rather broad, and might (at least in the mind of the lazy port hardware designer) include the maximum current that can be delivered by the computer's PSU. – Wouter van Ooijen Aug 02 '12 at 15:45
  • 1
    In the protocol, the port provides 100ma and the device can ask for more, up to 500ma (USB-1 spec; I know they keep jacking up the values). But I suspect you're talking about max current limits, and I suppose they didn't say that you couldn't supply more. Good point. – gbarry Aug 06 '12 at 20:22
  • 1
    @gbarry: The port provides *at least* 100mA, and the device can ask it to provide *at least* 500mA. I was responding to "compliant USB ports also limit the current", which is strictly true, but that limit is not necesarry the 100 or 500 mA that is often mentioned. – Wouter van Ooijen Aug 09 '12 at 16:26
5

I've had cheap USB cables which had those colour wires connected to the pins differently to "the spec".

Better to "buzz it out" I think.

Martin Thompson
  • 8,439
  • 1
  • 23
  • 44
  • They were the right colors??? – stevenvh Aug 02 '12 at 15:43
  • 2
    Right colours, wrong pins (but consistent at each end, so the cables worked OK) – Martin Thompson Aug 02 '12 at 15:46
  • 1
    I can second that, I've had USB cables that didn't even use the correct colored wires. My +5V cable was blue! – capcom Aug 02 '12 at 16:36
  • 4
    @capcom - If they don't follow the standard I would *prefer* that they would use other colors, then at least you know. If they're the standard colors you would expect that the connections are also standard. – stevenvh Aug 02 '12 at 17:28
  • 3
    Once upon a time I found a hard drive cable where +5 was yellow and +12 was red. Unfortunately we didn't notice until after we wired a kludge to the "5V" wire. That let the smoke out of the kludge, and caused much excitement. Since then, I always confirm any cable I'm hacking up before trusting that details like color codes are right. – RBerteig Aug 02 '12 at 18:18
1

All usb cable wiring is not same. So search on google for the wiring before you swap cables.

I only know Keyboard and data cable wiring, so here it is as an example: enter image description here

-1

When all else fails pull out your meter and test the wires coming out of the cable. That's what someone who isn't a fan of smoking anything inside my computer room that can't be bubbled through water would do.