No description
- Python 100%
Extracted from the cyberdeck repo. Verified live against the meter; display cross-check pins current scaling at /100 with 10mA BLE granularity (display resolves finer). |
||
|---|---|---|
| README.md | ||
| ud18.py | ||
atorch-ud18-bt
Bluetooth LE logger/CLI for the Atorch UD18 (HiDANCE) USB power meter.
Connects to the meter's UD18_BLE advertisement, subscribes to its report
notifications, decodes them, and prints/logs CSV — handy for unattended bench
power measurements (suspend drains, idle floors, charge curves).
Usage
Needs Python 3 + bleak. On NixOS:
nix-shell -p "python3.withPackages (p: [p.bleak])" --run "python3 ud18.py scan"
nix-shell -p "python3.withPackages (p: [p.bleak])" --run \
"python3 ud18.py log --seconds 60 --csv run.csv"
scan— find the meter (prefersUD18_BLE; ignores theUD18_SPPclassic-Bluetooth shadow advertisement, which BLE can't connect to).log [--seconds N] [--csv FILE] [--address MAC]— stream reports (~1 Hz):epoch,V,A,W,Wh,Dplus,Dminus,tempC.--seconds 0runs until Ctrl-C. Pass--addressto skip the scan.
Protocol
Community-documented Atorch BLE protocol (no reverse engineering needed —
see syssi/esphome-atorch-dl24
docs/protocol-design.md):
- GATT service
0xFFE0, characteristic0xFFE1(notify) - 32-byte report frames: magic
FF 55, message type01, device type03(USB meter), big-endian fields: voltage ×0.01 V @0x04(3B) · current @0x07(3B) · capacity ×0.001 Ah @0x0A(3B) · energy ×0.01 Wh @0x0D(4B) · D− ×0.01 V @0x11(2B) · D+ ×0.01 V @0x13(2B) · temp °C @0x15(2B) · runtime h/m/s @0x17 · checksum @0x1C
Caveats
- Current granularity: the BLE report steps in 10 mA units (
/100scaling confirmed by display cross-check: display 0.03294 A -> BLE raw 3 -> 0.030 A). The meter's own display resolves far finer (0.01 mA digits) -- use BLE logs for trends/loads >20 mA; read the display for single-digit-mA floors. - The UD18 measures D+/D− voltages but (at least on some port paths) does not pass USB data through — treat it as a power-only inline meter and verify your unit's port pairs if you need passthrough.
- Checksum is parsed-past, not verified (XOR-0x44 scheme per the protocol doc) — readings at 1 Hz over a desk are not exactly hostile RF territory.