powerz

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

Read the CLI reference Download a prebuilt binary

$ 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
Real 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.

All commands and flags

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_DATA for ADC, settings and the PD buffer
  • CONNECT and DISCONNECT
  • MemoryRead of 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

How the safety model works

Documentation