Table of Contents
Let’s learn about USB-PD and how to use it to power our electronics projects.
Using USB-PD will allow you to use hundreds of different power adapters and battery banks to supply a variety of voltages to your custom electronics designs.
Introduction
As electronics experimenters, students, and makers, we often require reliable and efficient power solutions for our projects. While power supplies are frequently an afterthought, they are critical components in any design.
A premade power supply has several advantages over a “home-brew” device. Not only is it convenient, but a proper supply has also been tested and certified by the authorities who regulate such things in your country (e.g., UL, CSA).
While traditional power sources like batteries and wall adapters have their place, USB Power Delivery (USB-PD) offers a modern, flexible, and efficient alternative. In this article, we’ll explore USB standards and USB-PD and how to use these adapters in your electronics projects.
We’ll also see how to use “trigger modules,” devices that negotiate power levels with USB-PD adapters. In addition to looking at a popular, inexpensive trigger module, we will also check out offerings from Adafruit and Sparkfun that allow you to use a microcontroller to select voltage levels.
Understanding USB
Before diving into USB-PD, let’s briefly review the evolution of USB connectors and standards.
Since its introduction in 1996, the Universal Serial Bus, or USB, has become a popular standard for connecting and powering devices. Initially designed to standardize computer connections for peripherals like keyboards and mice, USB now powers everything from smartphones to DIY electronics projects.
USB was developed by seven companies: Compaq, DEC, IBM, Intel, Microsoft, NEC, and Nortel. They intended to replace the serial and parallel cables commonly used for connecting peripherals like printers and mice with an easy-to-use standardized cable. Intel produced the first integrated circuits supporting USB in 1995.
The USB standard has evolved significantly in the nearly three decades since its inception, and many different types of connectors have been used.
USB Type-A and Type-B
The original USB connectors, Type-A and Type-B, are still widely used today. Type-A is the familiar flat, rectangular connector found on most computers, while Type-B is square with a slight slope at the top, often seen on printers and other peripherals.
These connectors have four connections:
- VBUS – Positive 5 Volts DC
- D- – Data –
- D+ Data +
- GND – Ground
The data is a “differential pair,” the signal being the difference between the two conductors. This arrangement allows for longer cable lengths.
This is a “single duplex” arrangement; the data can only travel in one direction. While this saves on wiring, it limits the maximum data transfer speed.
Advanced Type A
The Type A connector has been improved for use with more modern USB standards. Some versions of USB-A connectors have nine conductors instead of four; in these connectors, the extra pins are arranged so they don’t interfere with the four primary ones.
There is a color code for these connectors, but it is not official or adhered to by all manufacturers. This chart illustrates the color coding:
Mini USB
Early digital cameras and MP3 players popularized Mini USB. While it offered a smaller form factor than Type-A or Type-B, newer standards have largely replaced it due to speed and power capacity limitations.
With Mini USB came another wire, the “ID” signal. This was grounded on the “A Side” and left open on the “B Side,” allowing the cable to distinguish between hosts and devices.
The pinouts for Mini USB are as follows:
- VBUS – Positive 5 Volts DC
- D- – Data –
- D+ Data +
- ID – Identification
- GND – Ground
Micro USB
For several years, Micro USBs have become the most common connectors for smartphones and other small electronics. They provide a more compact connection than Mini USBs but offer limited power and data transfer capabilities compared to newer standards like USB-C.
Micro USB utilizes the same 5-wire pinout as Mini USB.
USB On-The-Go (OTG)
USB On-The-Go (OTG) allows devices to switch between host and peripheral roles, enabling features like direct data transfer between phones and external storage devices. This feature can be handy for makers building systems that interface directly with other devices without a computer.
USB OTG was introduced in 2001. It defines two roles for devices:
- OTG A-device – Power supplier.
- OTG B-device – Power consumer.
In the default configuration, the A-device acts as a USB host, with the B-device acting as a USB peripheral. The host and peripheral modes may be exchanged later using the Host Negotiation Protocol (HNP).
USB-C
USB-C represents a significant leap forward in USB technology. Its reversible design, compact size, and ability to handle high-speed data and power make it the new standard for many devices.
USB-C employs a 24-pin connector, 12 pins that are reversed and repeated on the opposite side of the connector shell. This arrangement permits the cable to be inserted in either direction, which is a consumer-friendly feature. Whereas earlier USB cables had a host end A and a peripheral device end B, a USB-C cable connects either way.
The pinout of USB-C is as follows. Note that there is a duplicate of each connection:
- GND – Ground
- SSTXp1 (“TX1+”) – SuperSpeed differential pair #1 & 3, transmit, positive
- SSTXn1 (“TX1-“) – SuperSpeed differential pair #1 & 3, transmit, negative
- VBUS – Bus power
- CC1 – Configuration channel
- D+ – USB 2.0 differential pair, position 1, positive
- D− – USB 2.0 differential pair, position 1, negative
- SBU1 – Sideband use (SBU)
- VBUS – Bus power
- SSRXn2 (“RX2-“) – SuperSpeed differential pair #2 & 4, receive, negative
- SSRXp2 (“RX2+”) – SuperSpeed differential pair #2 & 4, receive, positive
- GND – Ground
USB Standards
In the nearly three decades since its introduction, the Universal Serial Bus has undergone several revisions.
USB 1.0 & USB 2.0
The first widely adopted USB standards were USB 1.0 and 2.0, which focused on standardizing connections and data transfer for peripherals. They offered data transfer rates up to 12 Mbps (USB 1.0) and 480 Mbps (USB 2.0). These early versions also provided 5 volts at up to 500mA of power.
USB 3.0
USB 3.0 introduced SuperSpeed USB, dramatically increasing data transfer speeds to 5 Gbps. It also offered improved power delivery to 900mA at 5V.
USB 3.1
USB 3.1 Gen 1 maintained the 5 Gbps speed of USB 3.0, while Gen 2 doubled it to 10 Gbps. This standard also introduced enhanced power delivery features, allowing the delivery of up to 100W of power.
USB 3.2
USB 3.2 introduced multi-lane operation. This further improved data transfer rates, with Gen 2×2 offering up to 20 Gbps. It maintained backward compatibility with USB 3.1 and 3.0 devices.
USB4
USB4 is the most recent major update, boasting data rates up to 40 Gbps and native support for Thunderbolt 3 devices. It also expands USB-PD capabilities, enabling more efficient power delivery.
USB4 2.0
The latest USB standard, USB4 2.0, doubles the maximum data rate to 80 Gbps and introduces new features for display and data protocols. It also offers better power management, though it is still in its early stages of adoption.
USB Power Delivery (USB-PD)
USB Power Delivery, or USB-PD, was introduced in 2013 to allow USB to deliver more than the standard 5V at 500mA offered by older USB standards. The idea was to create a system where connected devices could negotiate power requirements, allowing anything from 5V to 20V and up to 100W of power. This made USB much more versatile for powering various devices, from phones to laptops and electronics projects.
USB-PD 3.2
USB-PD 3.2 is the current version of the Power Delivery standard. It offers more flexibility with power profiles and extends the maximum power to 240W for higher-powered devices.
Quick Charge (QC)
Quick Charge (QC) is a proprietary charging standard developed by Qualcomm. While it isn’t the same as USB-PD, it shares similar goals—faster and more efficient charging.
Quick Charge is widely used in smartphones and some USB power supplies. However, since it’s proprietary, it isn’t as flexible as USB-PD, which is an open standard. USB-PD will be more versatile for most electronics projects, but some makers may find Quick Charge useful for specific scenarios.
Using Power Trigger Modules
Power trigger modules are small circuits that negotiate power levels between a USB power source and your project. Based on your project’s requirements, they “trigger” the USB-PD to deliver a specific voltage, such as 9V or 12V.
ZY12PDN Trigger Module
The ZY12PDN is a popular and affordable USB-PD trigger module. The module handles the complex USB-PD handshake protocol, negotiating with the power supply to request specific voltages.
The ZY12PDN has an integrated pushbutton that allows users to select from multiple output voltages (5V, 9V, 12V, 15V, and 20V).
ZY12PDN Hookup
The ZY12PDN is very easy to hook up; simply plug it into a USB-C cable attached to a USB-PD charger and get the output on the terminal block.
Using the ZY12PDN
The ZY12PDN can be operated in two modes:
- Selectable – In this mode, the module defaults to 5-volts. You can use the push button to select a different voltage.
- Program/Fixed – In this mode, you can program the module to default to a different USB-PD voltage.
In both modes, the RGB LED will indicate the selected voltage as follows:
- Red – 5 Volts
- Yellow – 9 Volts
- Green – 12 Volts
- Teal – 15 Volts
- Blue – 20 Volts
- Purple – Highest Available Voltage (Program/Fixed mode only)
- White – Cycle Voltages (Program/Fixed mode only)
By default, the device will be in Selectable mode. You can use the push button to change the voltage, and the LED color will confirm your selection.
To put the device in Program mode to select a different default voltage, take the following steps:
- Remove the USB-C cable.
- Hold down the push button.
- Insert a USB-C cable (attached to a USB-PD charger).
- Release the push button.
- The LED indicator will rapidly flash, indicating you are in programming mode.
- Use the button to select the voltage.
- The ZY12PDN is now set for a fixed voltage.
Adafruit HUSB238
The Adafruit HUSB238 is a versatile USB-PD trigger board that can power various devices with different voltage requirements. It’s inexpensive and of the high quality you expect from an Adafruit product.
This board can be used as a stand-alone PD trigger board or an I2C-controlled trigger board. Adafruit provides software examples and libraries for CircuitPython and Arduino C++.
HUSB238 Pinouts
Here are the pinouts for the Adafruit HUSB238:
Note that the power output is available at the side of the board as well as on two pads spaced for a terminal block, which Adafruit includes with the module. The USB data lines are also made available.
HUSB238 Manual Voltage Selection
By default, the HUSB238 outputs 5 volts, which is limited to 1 amp. You can change this using a series of solder jumper pads.
The voltage selection is on the right side of the board. To change the voltage, cut the trace for the 5 volts and create a solder bridge on the terminal for the desired voltage. If you want 20 volts, just cut the 5-volt trace and don’t bridge anything.
You use a similar technique to set the current limiting on the left side of the board.
HUSB238 I2C Control
You can also control the board with I2C using the SDA, SCL, and Ground connections.
Note that this board does not have pull-up resistors or set an I2C reference voltage. You need to do all of that externally. The board’s default I2C address is 0x08.
The following is a hookup diagram for connecting an Arduino Uno to the HUSB238 module:
Adafruit provides code examples for both CircuitPython and Arduino C++. The video associated with this article demonstrates one of the C++ sample sketches included with the Arduino library, which can be installed using the Library Manager in the Arduino IDE.
SparkFun Power Delivery Board
The SparkFun Power Delivery Board is another excellent option for integrating USB-PD into your projects. This advanced USB-PD module has an integrated microcontroller.
Unlike the Adafruit HUSB238, the SparkFun Power Delivery Board cannot be used in a stand-alone fashion with jumpers; it needs to be controlled by an external microcontroller or microcomputer via the I2C port.
Power Delivery Board Pinouts
The board sports a USB-C connector and a QWIIC connector to simplify use. Output is on the end of the board, and solder pads for a terminal block are provided along with connections at the edge of the PCB.
The board also has several other connections, as illustrated here:
The board’s I2C address can be set using cut traces on the back. By default, it is 0x28.
Power Data Objects
A key concept when working with this board is the Power Data Object, or “PDO”. These are virtual objects that represent a power connection, and they contain four parameters:
- Voltage – The output voltage, from 5-20 volts (only USB-PD voltages)
- Over-Voltage Tolerance – From 5 – 20 percent, turns off when exceeded
- Under-Voltage Tolerance – From 5 to 20 percent, turns off when it falls below
- Current Limiting – 16 values from 0 to 5 amps
There are three PDO’s. PDO1 is fixed at 5 volts, and PDO2 and PDO3 can be set by the user.
The PDOs work on a priority system, with PDO3 having the highest priority, followed by PDO2. When reset, the board loads the highest priority PDO unless instructed otherwise. If the USB-PD power supply cannot provide the requested PDO parameters, then the next priority PDO is used.
SparkFun provides a library for the Arduino IDE to work with the PDOs. You can install it using the library manager. The video accompanying this article shows an example of setting and resetting PDOs.
Conclusion
USB-PD opens up a world of possibilities for powering your electronics projects. With its flexibility, efficiency, and increasing power capabilities, USB-PD is quickly becoming the go-to power solution for makers and experimenters. Whether you’re building a simple microcontroller project or a more complex creation, USB-PD can provide the power you need in a compact and convenient package.
You’ll see more of USB-PD here at the DroneBot Workshop, as I have a few USB-PD projects in store for you. Until then, happy experimenting!
Parts List
Here are some components you might need to complete the experiments in this article. Please note that some of these links may be affiliate links, and the DroneBot Workshop may receive a commission on your purchases. This does not increase the cost to you and is a method of supporting this ad-free website.
ZY12PDN Module Amazon
Adafruit HUSB238 Adafruit Store
SparkFun PD Board Sparkfun Store
Resources
Article PDF – A PDF version of this article in a ZIP file.
Adafruit HUSB238 – Guide from Adafruit for using the HUSB238 I2C Trigger Module.
SparkFun Power Delivery – SparkFuns guide to using their advanced Power Delivery board.
USB Implementers Forum – The official standard for USB