uint32_t corrected =
(rawIrms > zeroOffset) ? (rawIrms - zeroOffset) : 0;
In Example 08 (`Example08_DiagnosticTool`), the `z` command calculates a local
`zeroOffset` from raw IRMS readings. That offset is applied to the displayed
`Corrected` and `Averaged` raw values as above.
However, the displayed current in amps is obtained independently using:
mySensor.getCurrentA(amps);
Consequently, zero calibration does not affect the Amps field. For example,
after zeroing, Corrected may be near zero while Amps continues to show the
original no-load value.
Also, linear subtraction of two RMS magnitudes is not generally the correct
noise-floor correction. The library already provides autoCalibrateA(), which
performs the correction in the squared/RMS domain.
Would you consider changing the z command to use the library calibration?
For example:
void doZeroCalibration()
{
const uint16_t NUM_SAMPLES = 50;
Serial.println(
F("\nZero calibration - keep the CT connected with no current flowing."));
if (mySensor.autoCalibrateA(NUM_SAMPLES) != ksfTkErrOk)
{
Serial.println(F("Zero calibration failed!"));
return;
}
resetBuffer();
Serial.println(F("Channel A zero calibration complete.\n"));
}
The r command could correspondingly call:
mySensor.clearCalibration();
This would make the zero operation affect getCurrentA(amps) directly and
would avoid having two independent calibration paths in the example.