https://github.com/nbuchwitz/usb-meter
Python library for USB-C power meters. Initial support: ChargerLAB POWER-Z KM003C over its HID transport.
https://github.com/nbuchwitz/usb-meter
km003c meter power powerz usb
Last synced: 24 days ago
JSON representation
Python library for USB-C power meters. Initial support: ChargerLAB POWER-Z KM003C over its HID transport.
- Host: GitHub
- URL: https://github.com/nbuchwitz/usb-meter
- Owner: nbuchwitz
- License: lgpl-2.1
- Created: 2026-05-29T09:35:38.000Z (26 days ago)
- Default Branch: main
- Last Pushed: 2026-05-29T09:47:30.000Z (26 days ago)
- Last Synced: 2026-05-29T11:21:46.466Z (26 days ago)
- Topics: km003c, meter, power, powerz, usb
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# usb-meter
[](https://www.gnu.org/licenses/lgpl-2.1)
[](https://www.python.org/downloads/)
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.
## Features
- 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-meter` CLI for one-shot and streaming reads.
## Installation
Directly from GitHub:
```bash
pip install git+https://github.com/nbuchwitz/usb-meter.git
```
Or from a local checkout:
```bash
pip install .
```
Install the udev rule so non-root users in the `plugdev` group can
access the device:
```bash
sudo install -m 644 etc/udev/rules.d/60-chargerlab-km003c.rules /etc/udev/rules.d/
sudo udevadm control --reload && sudo udevadm trigger
```
## Usage
```python
from 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:
```bash
usb-meter -n 10 -i 0.2 # 10 samples, 200 ms apart
usb-meter -n 0 # stream forever
```
## Status
Alpha. 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.