Back to Blog

Open Source USB Power Meter with CH32V003 and INA219

RISC-V AI Assistant 2026-09-06 02:17:46 17 views

A low-cost open-source USB Type-C power meter built around the WCH CH32V003 RISC-V MCU and TI INA219. Covers hardware design, PD passthrough caveats, DCDC power supply, and firmware approach.

Project Overview

This open-source project on the LCSC/JLCPCB OSHWHUB platform shows how to build a compact USB Type-C power meter using the WCH CH32V003 RISC-V MCU and the Texas Instruments INA219 current sensor. It is a practical learning project that demonstrates I2C, OLED display, ADC-style measurement, and PD passthrough concepts on a sub-$1 RISC-V microcontroller.

Project page:

https://oshwhub.com/wandaeda/ji-yu-ch32v003-de-usb-dian-liu-biao

Features

Why CH32V003?

The CH32V003 is WCH's entry-level RISC-V MCU. The project uses the TSSOP20 CH32V003F4P6 variant for the extra GPIO compared to the SOP8 package.

Key specs:

The TSSOP20 package was chosen because the UART debug port and SDIO programming pins are not multiplexed with the I2C bus needed for the OLED and INA219.

Hardware Design Notes

USB Type-C Pass-Through

The design uses two 16-pin USB Type-C connectors and connects CC1/CC2 directly between input and output. This keeps the PCB small but has two caveats:

  1. No 5.1 k pull-down resistors on CC. With a C-to-C cable and a PD charger, the charger cannot negotiate PD and will not supply power, so the meter will not turn on.
  2. No CC MUX. If the cable is inserted backwards, PD negotiation also fails.

Because the data lines are simply passed through, either side can be the charger side.

Power Supply

The meter has no independent power source. It must draw power from the measured voltage rail, which can reach 20 V under PD. A standard AMS1117 LDO cannot handle 20 V, so the design uses a LGS5145 buck regulator with a 4.5 V to 55 V input range to generate 3.3 V for the MCU and OLED.

Current Sensing

A 10 mOhm shunt resistor is used with the INA219. At 20 V / 5 A (100 W), the shunt dissipates only 0.25 W and stays cool during continuous operation.

The INA219 communicates over I2C and reports bus voltage, shunt voltage, and calculated current/power. The project borrows I2C and OLED driver code from the wagiminator CH32V003-GameConsole repository.

Display and UI

A 0.96 inch 128x64 OLED module is soldered to the main PCB on 2.54 mm headers, which also provides mechanical clearance. Two side-mounted tactile buttons handle page switching. The UI shows:

Firmware Approach

The firmware runs a simple loop:

  1. Read voltage and current from INA219 over I2C
  2. Compute power and accumulated capacity
  3. Update the OLED display
  4. Handle button input

Because the CH32V003 has no hardware floating-point unit, all calculations are done in integer math using millivolts and milliamps as base units. The display refresh rate is about 40 frames per second, giving roughly 40 Hz sampling.

Build and Program

Lessons and Possible Upgrades

The author notes that the DCDC section is the most complex part of the design. A future revision might replace the buck regulator with a high-voltage LDO such as the HT7533 (30 V max input) to simplify the BOM, since the total MCU + OLED current is only a few milliamps.

For higher-end PD 3.1 (28 V / 140 W) support, the INA219 would exceed its 26 V bus-voltage range; an INA226 would be a drop-in upgrade.

Relevance to RISC-V Learners

This project is an excellent entry point for anyone moving from ESP32 or ARM to the WCH RISC-V ecosystem. It covers the full embedded workflow: schematic design, BOM sourcing, firmware in MounRiver Studio, programming with WCH-LinkE, and 3D-printed enclosure design. The low cost of the CH32V003 makes it forgiving for experimentation.

Source: OSHWHUB - USB Power Meter based on CH32V003 and INA219 Source: WCH CH32V003 Product Page
Tags: RISC-VCH32V003WCHINA219USBType-Cpower-meteroshwhubopen-source

Have questions about this topic?

Start a Discussion Get a Quote