Skip to content

Commit

Permalink
sns: fixup cse7766 calibration status err
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Oct 22, 2024
1 parent 766477f commit 8d115c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions code/espurna/sensors/CSE7766Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class CSE7766Sensor : public BaseEmonSensor {
}

if ((_data[0] & 0xFC) > 0xF0) {
_error = SENSOR_ERROR_OTHER;
_error = SENSOR_ERROR_VALUE;
#if SENSOR_DEBUG
if (0xF1 == (_data[0] & 0xF1)) DEBUG_MSG_P(PSTR("[SENSOR] CSE7766: Abnormal coefficient storage area\n"));
if (0xF2 == (_data[0] & 0xF2)) DEBUG_MSG_P(PSTR("[SENSOR] CSE7766: Power cycle exceeded range\n"));
Expand Down Expand Up @@ -288,9 +288,12 @@ class CSE7766Sensor : public BaseEmonSensor {

uint8_t byte = _serial->read();

// first byte must be 0x55 or 0xF?
// first byte is one one of
// - 0xAA - NOT calibrated
// - 0x55 - calibrated
// - 0xF? - abnormal state
if (0 == _data_index) {
if ((0x55 != byte) && (byte < 0xF0)) {
if ((0xAA != byte) && (0x55 != byte) && (byte < 0xF0)) {
continue;
}

Expand Down

0 comments on commit 8d115c0

Please sign in to comment.