MilikMilik

Build Open-Source USB-C Power Tools and Smart Power Meters

Build Open-Source USB-C Power Tools and Smart Power Meters
Interest|Open-Source Hardware

What Open-Source Power Management Boards Are and Why They Matter

Open-source power management boards are DIY hardware projects that combine USB-C Power Delivery, low-cost microcontrollers, and energy monitoring sensors to give makers fine-grained control over voltage selection, current measurement, and real-time power analysis without relying on proprietary black-box modules. They provide published schematics, firmware, and fabrication files so you can study, modify, and reuse proven designs in your own USB-C PD voltage selector and smart power meter DIY builds, while learning how modern power delivery and energy monitoring hardware works at a practical, hands-on level.

If you enjoy building bench tools and small power gadgets, two types of boards are especially rewarding: a USB-C PD voltage selector and a smart VA (voltage–ampere) meter. The first gives you a tiny, configurable USB-C power brick that can output several PD voltages on demand. The second turns into a multi-app energy monitoring station with live graphs and efficiency calculations. Both projects are open-source power management designs; the creators publish code, schematics, and even Gerber/BOM/CPL fabrication files so you can reproduce or adapt them without licensing locks. They also highlight how cheap open microcontrollers, including RISC-V microcontroller projects such as the CH32V003F4P6, can handle serious power-delivery tasks while costing about 10 cents per chip.

Build Open-Source USB-C Power Tools and Smart Power Meters

Parts You Need for a USB-C PD Voltage Selector and Smart Power Meter

Before you grab the soldering iron, it helps to know what hardware is involved in each build. The USB-C PD voltage selector revolves around a PD sink controller and an ultra-cheap RISC-V microcontroller, while the smart power meter relies on precision current and voltage sensors plus a microcontroller platform with display and networking.

  • USB-C PD voltage selector core components: - USB Type‑C connector - CH224K USB PD sink controller - CH32V003F4P6 RISC-V microcontroller (QingKe 32-bit RISC-V2A core up to 48 MHz) - LM317DCYR adjustable regulator (set to 3.3 V for the MCU) - LEDs and indicator circuitry (including a Power Good LED driven by the CH224K PG pin) - 1 kΩ and 10 kΩ resistors, voltage divider resistors - 100 nF, 1 µF, and 16 pF capacitors - Push button switch, screw terminal block - Custom PCB ordered from a board house using provided Gerber/BOM/CPL files
  • Smart power meter DIY building blocks: - Two INA226 current/voltage sensors configured as ina226_Low and ina226_High on an I2C bus - Microcontroller platform with display libraries and a canvas for UI rendering - Relay output (RELAY_PIN), buzzer (BUZZER_PIN), and power enable/control pins for switching loads - Encoder inputs for menu navigation and buttons for control - Firmware that tracks bus voltage, current, power, total energy in Wh, and logs data for live graphing

One critical warning: the LM317-based 3.3 V rail must be configured before soldering the CH32V003 microcontroller; the author notes, “Solder the MCU after configuring the LM317 potentiometer to 3.3V; otherwise, you will burn the MCU.” That is the single easiest mistake to avoid, so treat it as a hard rule.

Step-by-Step: Building and Bringing Up the USB-C PD Voltage Selector

The USB-C PD voltage selector is designed to give you a clean way to switch between 5 V, 9 V, 12 V, 15 V, and 20 V from a single USB-C PD charger using one button and a few LEDs. It uses the CH224K, which negotiates PD profiles via three configuration pins, and the CH32V003, which drives those pins to pick a mode dynamically. The goal: a small, reliable tool you can plug into any PD charger and treat as a configurable lab supply.

  1. Assemble and power the 3.3 V rail: Populate the LM317, associated resistors, and capacitors, but leave the microcontroller unsoldered. Apply a temporary input and adjust the potentiometer until the output measures 3.3 V. Only after confirming this should you solder the CH32V003; otherwise, you risk burning the MCU.
  2. Populate the CH224K and USB-C path: Solder the USB Type-C connector, the CH224K USB PD sink controller, and their surrounding passives, including voltage divider resistors, decoupling capacitors, and the Power Good LED with its 1 kΩ resistor between the PG pin and ground. Verify for shorts on the PD and 5–20 V output traces.
  3. Wire LEDs, button, and CFG pins: Add the push button switch, status LEDs, and resistors. Connect the CH32V003 GPIO pins to CH224K CFG1, CFG2, and CFG3 so the MCU can change requested PD voltages under firmware control. Ensure the LED outputs correspond to the planned modes (5 V, 9 V, 12 V, 15 V, 20 V).
  4. Flash firmware and validate button logic: Load the provided firmware that initializes the system clock, delay timer, and GPIO, sets modeIndex to 0 (default 5 V), and then sits in an infinite loop reading the button. The readButton() function uses debouncing and rising-edge detection, incrementing modeIndex and wrapping after 5 states, then calling applyMode() to reconfigure the CH224K.
  5. Test with a USB meter and multimeter: Start with a USB meter in series with the charger so you can monitor current and provide overcurrent protection; if something fails, power is cut before damage occurs. Once idle current and behavior look safe, switch to the charger directly and connect a multimeter across the output to log each PD step’s voltage. Confirm that pressing the button cycles through all voltages and that the Power Good LED lights only when the CH224K successfully negotiates the requested mode.

A common gotcha, besides the 3.3 V rail, is forgetting that 5 V is the safest default. The firmware’s main() explicitly boots into 5 V mode before any interaction, giving you a friendly startup state for random PD chargers. Another subtle feature is that the Power Good LED is driven directly from the CH224K’s PG pin, not from the microcontroller; if PG stays low, negotiation failed and you should not trust the output.

How the Firmware and RISC-V MCU Make the Selector Work

What makes this USB-C PD voltage selector special is how much it does with a tiny 32-bit RISC-V microcontroller. The CH32V003F4P6 uses a QingKe 32-bit RISC-V2A core running up to 48 MHz, which is more than enough for reading a button, driving three configuration pins, and blinking a couple of LEDs. According to the project author, “CH32V003F4P6 is WCH’s ultra-low-cost $0.10 MCU. Despite the price, it is surprisingly capable for simple control tasks like this project.”

The firmware follows a clear structure: initialization, then a tight event loop. The main() function updates the system clock, initializes delay functions, configures GPIOs, sets modeIndex to 0, calls applyMode() to request 5 V, and then enters an infinite loop where it continuously polls the button. The readButton() routine implements debouncing: it checks for a transition from low to high (rising edge), applies a 20 ms delay to filter mechanical bounce, then increments the mode index with wrap-around and calls applyMode().

Because CFG1–CFG3 define which PD profile the CH224K asks for, applyMode() maps each modeIndex (0–4) to a bit pattern and updates those pins. When negotiation succeeds, the CH224K asserts PG, lighting the Power Good LED so you get a hardware-level confirmation that the requested voltage is stable. This is a good example of RISC-V microcontroller projects in real power delivery: small code, clear behavior, and a visible link between firmware and power hardware.

Turning Dual INA226 Sensors into a Smart Energy Monitoring Station

Once you have a controllable PD source, the next logical project is energy monitoring hardware that can tell you what loads are doing in real time. The smart VA meter project builds a full-featured smart power meter DIY system using two INA226 sensors—configured as ina226_Low at address 0x40 and ina226_High at 0x41—on an I2C bus. These measure bus voltage and shunt current, allowing the firmware to compute instantaneous power, cumulative energy in Wh, and efficiency metrics.

The firmware tracks variables such as bus voltage, current in amperes, power in watts, and total energy in watt-hours. It also supports a live dual-trace graph: history arrays for power and voltage store up to GRAPH_PTS = 200 samples, with recording controlled by isGraphRecording and a tick rate (graphTickRate) of 500 ms. A display canvas draws dashboards, live graphs, and menus that are organized into nine apps: DASHBOARD, RELAY CTRL, POWER UNIT, EFFICIENCY, EFF RESULTS, AUTOMATION, WIFI PORTAL, LIVE GRAPH, and SETTINGS.

Hardware-wise, the smart meter includes relay, buzzer, and power control pins (RELAY_PIN, BUZZER_PIN, ISO_POWER_EN_PIN, CURRENT_MODE_PIN) for switching loads and indicating alarms. Combined with encoder inputs and on-device settings like calibration multipliers and screen brightness, the device becomes more than a simple meter—it is a small power controller that can switch outputs based on measured energy and user scripts. This makes it ideal for testing DC-DC converters, USB loads, and battery efficiency when paired with the USB-C PD voltage selector.

Milik earns a commission when you shop through our links, at no extra cost to you. This article was generated with AI from published sources and product data.

Related Products

You May Also Like

Comments
Say something...
No comments yet. Be the first to share your thoughts!