DIY Electronics
— Building circuits, programming microcontrollers, and making things blinkBuilding a simple AM radio receiver from scratch
Building a USB Power Meter with INA3221
The INA3221 measures voltage and current on three channels simultaneously over I2C, which makes it ideal for a multi-rail power meter. I used it to build a USB-C power delivery analyzer.
The device sits inline on two USB-C conductors, measuring VBUS current and voltage plus the CC wire voltages to decode PD negotiation. An STM32F103 (Blue Pill) reads the INA3221 and drives a small OLED display showing real-time power on each rail. A circular buffer in SRAM stores the last 60 seconds of readings for peak detection.
Calibration: the INA3221 shunt resistors need to be matched — I used 0.02 ohm 1% resistors for good accuracy without excessive voltage drop at high current. At 5A USB-C output, the shunt drops only 100mV, acceptable for PD operation. The measured values match my bench meter within 1%.