Browse Source

Merge pull request #1665 from mcspr/cse7766-count

Fix CSE7766 magnitude count
rules-rpn
Xose Pérez 5 years ago
committed by GitHub
parent
commit
edef1631df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      code/espurna/sensors/CSE7766Sensor.h

+ 6
- 6
code/espurna/sensors/CSE7766Sensor.h View File

@ -22,7 +22,7 @@ class CSE7766Sensor : public BaseSensor {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
CSE7766Sensor(): BaseSensor(), _data() { CSE7766Sensor(): BaseSensor(), _data() {
_count = 6;
_count = 7;
_sensor_id = SENSOR_CSE7766_ID; _sensor_id = SENSOR_CSE7766_ID;
} }
@ -161,7 +161,7 @@ class CSE7766Sensor : public BaseSensor {
if (index == 0) return MAGNITUDE_CURRENT; if (index == 0) return MAGNITUDE_CURRENT;
if (index == 1) return MAGNITUDE_VOLTAGE; if (index == 1) return MAGNITUDE_VOLTAGE;
if (index == 2) return MAGNITUDE_POWER_ACTIVE; 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 == 4) return MAGNITUDE_POWER_APPARENT;
if (index == 5) return MAGNITUDE_POWER_FACTOR; if (index == 5) return MAGNITUDE_POWER_FACTOR;
if (index == 6) return MAGNITUDE_ENERGY; if (index == 6) return MAGNITUDE_ENERGY;
@ -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) { if (apparent > active) {
_reactive = sqrt(apparent * apparent - active * active); _reactive = sqrt(apparent * apparent - active * active);
} else { } else {


Loading…
Cancel
Save