Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamHow to wire a USB cable correctly
For a standard USB 2.0 cable, wire it as follows:
| USB signal | Usual wire color | Function |
|---|---|---|
| VBUS | Red | +5 V power |
| D− | White | USB data negative |
| D+ | Green | USB data positive |
| GND | Black | Ground |
| Shield / drain | Bare / braid / foil | Connector shell / shield |
The most common USB 2.0 pinout is:
| Pin | Signal | Usual color |
|---|---|---|
| 1 | VBUS, +5 V | Red |
| 2 | D− | White |
| 3 | D+ | Green |
| 4 | GND | Black |
Important: Do not rely on wire color alone. Cheap or non-standard cables may use different colors. Always confirm with a multimeter continuity test before plugging the cable into a computer, charger, phone, microcontroller board, or other device.
USB wiring depends on the connector and USB generation. The simple red/white/green/black wiring applies mainly to USB 2.0 Type-A, Type-B, Mini-USB, and Micro-USB cables.
Common cases:
| Connector type | Typical difficulty | Notes |
|---|---|---|
| USB-A / USB-B 2.0 | Easy | 4 conductors: VBUS, D−, D+, GND |
| Mini-USB / Micro-USB 2.0 | Moderate | 5 pins; extra ID pin for OTG |
| USB 3.x Type-A / Type-B / Micro-B | Difficult | Extra high-speed differential pairs |
| USB-C | More complex | Requires CC pins, orientation handling, and sometimes e-marker circuitry |
For a repair or DIY cable, USB 2.0 is the practical one to hand-wire. USB 3.x and USB-C cables are much more sensitive to impedance, shielding, connector geometry, and power negotiation.
A standard USB 2.0 cable has four main wires:
| Signal | Meaning | Typical color | Connection |
|---|---|---|---|
| VBUS | +5 V supply | Red | Pin 1 |
| D− | Negative data line | White | Pin 2 |
| D+ | Positive data line | Green | Pin 3 |
| GND | Ground return | Black | Pin 4 |
| Shield | EMI shielding | Bare/braid | Connector shell |
USB data is carried on the D+ and D− differential pair. These two wires should ideally remain twisted together as much as possible. Untwisting them too far can make the cable unreliable, especially at full-speed or high-speed USB 2.0 operation.
USB 2.0 speeds include:
| Mode | Speed |
|---|---|
| Low-speed | 1.5 Mbit/s |
| Full-speed | 12 Mbit/s |
| High-speed | 480 Mbit/s |
At 480 Mbit/s, cable quality matters. For short repair lengths, careful hand wiring can work, but for long cables or reliable high-speed operation, use a proper manufactured cable.
For a standard USB-A connector, the signal order is:
Pin 1: +5 V / VBUS
Pin 2: D−
Pin 3: D+
Pin 4: GND
Shell: Shield
Usually:
Red → VBUS / +5 V
White → D−
Green → D+
Black → GND
Bare → Shield / shell
Be careful with connector orientation. The safest method is to check the connector datasheet or use continuity testing against a known good cable or connector.
USB-B, often used on printers, instruments, Arduino Uno-style boards, and older equipment, uses the same four USB 2.0 signals:
| Pin | Signal |
|---|---|
| 1 | VBUS |
| 2 | D− |
| 3 | D+ |
| 4 | GND |
The wiring is electrically the same as USB-A, but the physical pin layout is different. Do not assume the left-to-right order visually without checking the connector orientation.
Micro-USB and Mini-USB have five pins, not four:
| Pin | Signal | Usual function |
|---|---|---|
| 1 | VBUS | +5 V |
| 2 | D− | Data negative |
| 3 | D+ | Data positive |
| 4 | ID | OTG identification |
| 5 | GND | Ground |
For a normal USB device cable:
Pin 1 → +5 V
Pin 2 → D−
Pin 3 → D+
Pin 4 → Leave unconnected
Pin 5 → GND
For a USB OTG cable:
ID pin → GND
Grounding the ID pin tells an OTG-capable device to act as the host. Leaving the ID pin floating is used for the normal peripheral/device side.
This is a common source of mistakes.
For modern devices, the main practical trend is the move toward USB-C. However, USB-C is not simply “USB with a different connector.” It includes:
For simple hobby use, the best practice is usually:
For electronics projects, USB-C breakout boards with proper 5.1 kΩ pull-down resistors on CC1 and CC2 are commonly used when the project is a USB-C powered device receiving 5 V.
If you only need power, for example to power a small 5 V device:
Red → +5 V
Black → GND
The white and green data wires may be left unconnected.
However, some chargers and devices use data-line behavior to detect charging capability. A simple power-only cable may work with many devices, but some phones, tablets, or USB battery packs may limit current or refuse to charge properly without correct USB charging identification.
For data transfer, all four conductors are needed:
Red → +5 V
White → D−
Green → D+
Black → GND
If D+ and D− are swapped, the device will usually not enumerate. It may power on, but the computer will not recognize it.
The cable shield or drain wire should normally connect to the metal shell of the USB connector.
In a cable repair, this generally means:
Bare shield/drain wire → connector shell
The shield improves electromagnetic compatibility and reduces noise susceptibility. For short low-speed charging cables, the shield may not seem critical, but for reliable data operation it is important.
Use:
Cut and strip the cable
Identify the wires
Strip the conductors
Tin the wires
Tin the connector pads
Solder the wires
Connect the shield
Inspect carefully
Test with a multimeter
Insulate and strain-relieve
| Mistake | Result |
|---|---|
| Swapping red and black | Can destroy connected electronics |
| Swapping D+ and D− | Device powers but is not detected |
| Shorting VBUS to GND | Can damage host port or charger |
| Forgetting strain relief | Cable fails mechanically |
| Overheating connector | Melted plastic, shifted pins |
| Relying only on color code | Incorrect wiring if cable is non-standard |
| Hand-wiring USB 3.x pairs poorly | Unstable or no high-speed data |
| Treating USB-C like simple USB-A | Incorrect or unsafe behavior |
For USB-C, a simple four-wire connection is often not enough.
For a USB-C device that wants to receive normal 5 V power from a USB-C source, the receptacle generally needs:
VBUS → +5 V input
GND → Ground
CC1 → 5.1 kΩ to GND
CC2 → 5.1 kΩ to GND
D+ → USB D+
D− → USB D−
But exact wiring depends on whether you are building:
For USB-C, using a proper breakout board or certified cable is strongly recommended.
To wire a basic USB 2.0 cable correctly:
Red → +5 V / VBUS
White → D−
Green → D+
Black → GND
Bare shield → Connector shell
For Micro-USB or Mini-USB, use the same power and data signals, but remember the extra ID pin. Leave ID floating for a normal device cable; connect ID to ground for OTG host mode.
For USB-C or USB 3.x, avoid hand-wiring unless you know the exact connector requirements. Use a breakout board or certified cable whenever possible.