Measure USB‑C power from the command line.
powerz is a read-only CLI and Go library for the ChargerLAB POWER-Z KM003C. Piped output is JSON with units in the field names, errors have stable exit codes, and powerz schema describes the whole interface, so scripts and AI agents can drive the meter as easily as you can.
brew install libusb pkgconf
go install github.com/ljagiello/gopower-z/cmd/powerz@latest
sudo apt install libusb-1.0-0-dev pkg-config
go install github.com/ljagiello/gopower-z/cmd/powerz@latest
$ powerz read
KM003C, fw 1.9.5
- VBUS
"vbus_v" - 5.0765V
- IBUS
"ibus_a" - 0.1326A
- Power
"power_w" - 0.6730W
27.9 °C
Type-C attached on CC2, source advertises 3.0A
powerz read output from a KM003C powering a test board.Commands
On a terminal, plain powerz opens a live dashboard. Piped, it prints one JSON reading. Every command below has a fixed output shape.
powerz read- One snapshot: VBUS, IBUS, power, temperature, CC and D+/D− lines.
powerz measure --duration 10s- Min, mean and max of V, A and W, plus Wh, mAh and the USB-PD contract.
powerz log --format csv- A stream of snapshots as JSON lines or CSV.
powerz pd --duration 30s- Decoded USB Power Delivery messages, then a summary line.
powerz info- Model, firmware and hardware versions, serial, settings.
powerz schema- Every command, flag, field and exit code, as JSON, for agents.
Read-only by design
Every frame is checked against a whitelist right before it goes to the meter, and a fuzz test proves the whitelist accepts nothing else. powerz cannot change the voltage on the bus.
Sent
GET_DATAfor ADC, settings and the PD bufferCONNECTandDISCONNECTMemoryReadof three fixed 64-byte information blocks
Never sent
- Settings writes and factory reset
- Firmware and DFU commands
- Authentication and stream control
- CDC text commands that make a charger raise VBUS
Documentation
How the meter works
- USB protocolThe KM003C protocol byte by byte, with sources and results verified on a real device.
- HardwareSpecs, components, sample rates, teardown notes and official downloads.
- Official softwareHow ChargerLAB's Windows app talks to the meter, from decompilation.
- FirmwareThe
.mencryptcontainer and analysis of the meter firmware.