Summary
_read_metadata() in src/ppk2_api/ppk2_api.py returns as soon as a single serial read buffer contains "END", without accumulating data from earlier reads. When the PPK2 firmware sends its calibration metadata split across multiple USB serial buffers, calibration fields from earlier chunks are silently discarded and remain at their default value of 0.
This causes systematically wrong current readings at low µA ranges, with no warning or error.
Expected behaviour
The full metadata string (multi-line ASCII, ending with END) should be assembled from all serial reads before parsing — matching the official nRF Connect Power Profiler, which accumulates chunks until "END" appears in the combined string.
Actual behaviour
When metadata is split across two (or more) USB reads:
- First read: e.g.
Calibrated: 0, O0–O4, S0–S4, … (no END yet) → loop continues, data is not kept
- Second read: e.g.
HW: …, END → function returns only this chunk
_parse_metadata() never sees O0, S0, HW, etc. → they stay at default 0
Impact
At the lowest measurement range (range 0, ~µA scale), O[0] is the factory ADC zero-point offset (typically ~166 ADC counts). With O[0] = 0: result = (adc - O[0]) × (adc_mult / R[0]) applies no zero-point correction, adding a fixed offset of roughly ~1.8 µA to every sample (depending on hardware, some are 0.6µA, some 2.0µA). Readings in the low-µA range are systematically too high, with no error raised.
Reproduction
- Use a factory-calibrated PPK2 (
Calibrated: 0 in metadata).
- Connect on a platform where metadata spans multiple serial reads (observed on macOS, metadata split across 2 reads).
- Call
get_modifiers() and log the raw metadata string — fields like O0:–O4: and HW: are missing from the returned string even though the device sent them.
- Measure a low-current load (< 5 µA) and compare with nRF Connect Power Profiler — this library reads ~1.8 µA higher.
Solution
I have the correction but i can't push a branch.
Summary
_read_metadata()insrc/ppk2_api/ppk2_api.pyreturns as soon as a single serial read buffer contains"END", without accumulating data from earlier reads. When the PPK2 firmware sends its calibration metadata split across multiple USB serial buffers, calibration fields from earlier chunks are silently discarded and remain at their default value of0.This causes systematically wrong current readings at low µA ranges, with no warning or error.
Expected behaviour
The full metadata string (multi-line ASCII, ending with
END) should be assembled from all serial reads before parsing — matching the official nRF Connect Power Profiler, which accumulates chunks until"END"appears in the combined string.Actual behaviour
When metadata is split across two (or more) USB reads:
Calibrated: 0,O0–O4,S0–S4, … (noENDyet) → loop continues, data is not keptHW: …,END→ function returns only this chunk_parse_metadata()never seesO0,S0,HW, etc. → they stay at default0Impact
At the lowest measurement range (range 0, ~µA scale),
O[0]is the factory ADC zero-point offset (typically ~166 ADC counts). WithO[0] = 0: result = (adc - O[0]) × (adc_mult / R[0]) applies no zero-point correction, adding a fixed offset of roughly ~1.8 µA to every sample (depending on hardware, some are 0.6µA, some 2.0µA). Readings in the low-µA range are systematically too high, with no error raised.Reproduction
Calibrated: 0in metadata).get_modifiers()and log the raw metadata string — fields likeO0:–O4:andHW:are missing from the returned string even though the device sent them.Solution
I have the correction but i can't push a branch.