Python library for USB-C power meters. Initial support: ChargerLAB POWER-Z KM003C over its HID transport.
The library talks directly to /dev/hidraw*, so it does not fight with
the upstream Linux powerz kernel driver (which binds to the device's
vendor-bulk interface and exposes a small subset of values via hwmon).
It also has no third-party dependencies.
- Find a connected meter by USB vendor/product id.
- Read ADC samples (VBUS, IBUS, VCC1/2, VDP/M, VDD, temperature).
- Compact wire-protocol primitives (message + extension header, opcode and attribute enums) shared with the KM002C.
usb-meterCLI for one-shot and streaming reads.
Directly from GitHub:
pip install git+https://github.com/nbuchwitz/usb-meter.gitOr from a local checkout:
pip install .Install the udev rule so non-root users in the plugdev group can
access the device:
sudo install -m 644 etc/udev/rules.d/60-chargerlab-km003c.rules /etc/udev/rules.d/
sudo udevadm control --reload && sudo udevadm triggerfrom usb_meter import KM003C
with KM003C.open() as meter:
sample = meter.read_adc()
print(f"{sample.vbus_v:.3f} V, {sample.ibus_a:.3f} A, {sample.temperature_c:.1f} C")Or from the shell:
usb-meter -n 10 -i 0.2 # 10 samples, 200 ms apart
usb-meter -n 0 # stream foreverAlpha. Only ADC reading is implemented today. The vendor protocol
documents more attributes (PD_PACKET, ADC_QUEUE_10K, SETTINGS,
etc.) that map to the same request/response shape and will land here
incrementally.