In the past, I have worked on Power Delivering (PD) ICs. They are perfect for getting instant voltage from a GaN charger. I made a simple, standalone board that lets me select different PD voltages by charging the register settings. But why not keep it more usable with a single-button setup and a 10-cent microcontroller? No OLED displays, no rotary encoders, no over-engineering, just a simple toggle button with a few LEDs. That is exactly what I built in this project using the CH224K USB PD sink controller and the CH32V003F4P6, both made on WCH hardware.

The idea is straightforward. You plug in a USB-C PD charger, press the button to cycle through 5V, 9V, 12V, 15V, and 20V, and the corresponding LED lights up to tell you which voltage is currently active. I have designed the circuit in EasyEDA and manufactured the PCB with JLCPCB to realize this idea. In this session, I will share the code and hardware files so you can easily build your own. Let’s get started.

What Is USB Power Delivery?

Traditional USB ports give you 5V, and that is it. USB PD is a protocol that allows a charger and a device to negotiate higher voltages and currents over the USB-C cable. A typical USB PD charger can deliver 5V, 9V, 12V, 15V, and 20V, with a maximum power of 100W. This came into play when fast charging became popular in mobile phones: it is easy to charge at a higher voltage while fast charging because the mobile's internal circuits buck down and charge the battery at a higher current locally.

This negotiation happens over the CC (Configuration Channel) lines on the USB-C connector. The sink device tells the source what voltage it wants, and the source either agrees or offers the closest available option. This makes PD sink boards incredibly useful for makers and electronics hobbyists. Here, I have a dedicated chip for all this: CH224K. Based on three configuration pins (CFG1, CFG2, CFG3), it automatically negotiates the voltage with the PD source. You can use fixed resistor values, or you can drive the CFG pins with a microcontroller for dynamic voltage selection, which is exactly what I am doing here.

Key features of the CH224K:

  • Supports USB PD 2.0 and 3.0 protocols
  • Selectable output voltages: 5V, 9V, 12V, 15V, and 20V
  • Three configuration pins (CFG1, CFG2, CFG3) for voltage selection
  • Power Good (PG) output for voltage-ready indication
  • Built-in CC pull-down resistors for USB-C detection
  • Available in a compact SOP-10 package
  • Operating supply voltage: 3.3V to 5.5V

Choosing a microcontroller for action

The main problem is the device's cost; I cannot pick a controller that exceeds the device's cost beyond the actual functionality cost. CH32V003F4P6 is WCH's ultra-low-cost $0.10 MCU. Despite the price, it is surprisingly capable for simple control tasks like this project.

Key specifications of the CH32V003F4P6:

  • Core: QingKe 32-bit RISC-V2A, up to 48 MHz
  • Flash: 16 KB
  • SRAM: 2 KB
  • Package: TSSOP-20 (20 pins)
  • GPIO: 18 I/O pins
  • Peripherals: USART, I2C, SPI, ADC, timers
  • Operating voltage: 3.3V to 5V
  • Cost: approximately $0.10

For this project, I am using 9 GPIO pins total. 3 for driving the CH224K configuration pins, 5 for the indicator LEDs, and 1 for reading the push button.

Components Required

Here is the complete list of components I used for this project:

  • USB Type‑C Connector
  • CH224K
  • CH32V003F4P6
  • LM317DCYR
  • LEDs
  • 1 kΩ Resistors
  • 10 kΩ Resistors
  • Voltage Divider Resistors
  • 100 nF Capacitors
  • 1 µF Capacitors
  • 16 pF Capacitor
  • Push Button Switch
  • Screw Terminal Block
  • Custom PCB from JLCPCB

Circuit Diagram

The USB Type-C connector is a standard 16-pin one. The VBUS pins carry the PD voltage from the charger, and the CC1/CC2 lines connect directly to the CH224K for PD communication. The three configuration pins CFG1, CFG2, and CFG3 are connected to the MCU's PD2, PD3, and PD4 pins, respectively.

There is a 10K pull-down resistor on the VDD line and decoupling capacitors to provide clean power to the IC. The...

Read more »