Skip to content

Commit

Permalink
Merge pull request #1665 from mcspr/cse7766-count
Browse files Browse the repository at this point in the history
Fix CSE7766 magnitude count
  • Loading branch information
xoseperez authored Mar 29, 2019
2 parents 976be21 + 594e978 commit edef163
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions code/espurna/sensors/CSE7766Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CSE7766Sensor : public BaseSensor {
// ---------------------------------------------------------------------

CSE7766Sensor(): BaseSensor(), _data() {
_count = 6;
_count = 7;
_sensor_id = SENSOR_CSE7766_ID;
}

Expand Down Expand Up @@ -161,7 +161,7 @@ class CSE7766Sensor : public BaseSensor {
if (index == 0) return MAGNITUDE_CURRENT;
if (index == 1) return MAGNITUDE_VOLTAGE;
if (index == 2) return MAGNITUDE_POWER_ACTIVE;
if (index == 3) return MAGNITUDE_POWER_REACTIVE;
if (index == 3) return MAGNITUDE_POWER_REACTIVE;
if (index == 4) return MAGNITUDE_POWER_APPARENT;
if (index == 5) return MAGNITUDE_POWER_FACTOR;
if (index == 6) return MAGNITUDE_ENERGY;
Expand Down Expand Up @@ -275,10 +275,10 @@ class CSE7766Sensor : public BaseSensor {
}
}

// Calculate reactive power
_reactive = 0;
unsigned int active = _active;
unsigned int apparent = _voltage * _current;
// Calculate reactive power
_reactive = 0;
unsigned int active = _active;
unsigned int apparent = _voltage * _current;
if (apparent > active) {
_reactive = sqrt(apparent * apparent - active * active);
} else {
Expand Down

0 comments on commit edef163

Please sign in to comment.