Browse Source

Filter off-limits in HLW8012 readings

fastled
Xose Pérez 7 years ago
parent
commit
ac179daa17
3 changed files with 8 additions and 6 deletions
  1. +1
    -1
      code/espurna/config/hardware.h
  2. +3
    -1
      code/espurna/config/sensors.h
  3. +4
    -4
      code/espurna/pow.ino

+ 1
- 1
code/espurna/config/hardware.h View File

@ -58,7 +58,7 @@
#define LED1_PIN_INVERSE 0
#define BUTTON1_PIN 4
#define BUTTON1_RELAY 1
#define BUTTON1_MODE BUTTON_SWITCH
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define ENABLE_POW 1
// -----------------------------------------------------------------------------


+ 3
- 1
code/espurna/config/sensors.h View File

@ -118,8 +118,10 @@
#define POW_ENERGY_TOPIC "energy"
#define POW_UPDATE_INTERVAL 5000
#define POW_REPORT_EVERY 12
#define POW_MIN_POWER 10
#define POW_MIN_POWER 5
#define POW_MAX_POWER 2500
#define POW_MIN_CURRENT 0.05
#define POW_MAX_CURRENT 10
//--------------------------------------------------------------------------------
// Internal power montior


+ 4
- 4
code/espurna/pow.ino View File

@ -96,25 +96,25 @@ void powReset() {
unsigned int getActivePower() {
unsigned int power = hlw8012.getActivePower();
if (power < POW_MIN_POWER) power = 0;
if (POW_MIN_POWER > power || power > POW_MAX_POWER) power = 0;
return power;
}
unsigned int getApparentPower() {
unsigned int power = hlw8012.getApparentPower();
if (power < POW_MIN_POWER) power = 0;
if (POW_MIN_POWER > power || power > POW_MAX_POWER) power = 0;
return power;
}
unsigned int getReactivePower() {
unsigned int power = hlw8012.getReactivePower();
if (power < POW_MIN_POWER) power = 0;
if (POW_MIN_POWER > power || power > POW_MAX_POWER) power = 0;
return power;
}
double getCurrent() {
double current = hlw8012.getCurrent();
if (current < POW_MIN_CURRENT) current = 0;
if (POW_MIN_CURRENT > current || current > POW_MAX_CURRENT) power = 0;
return current;
}


Loading…
Cancel
Save