From d57eb0721b7096f9e08448eebab2597e8cb52491 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Sat, 18 Jul 2020 01:09:38 +0300 Subject: [PATCH] sns: power factor fixes (#2303) * Update PZEM004TV30Sensor.h See table above for the correct scale * Power factor has no unit --- code/espurna/sensors/BaseSensor.h | 3 +-- code/espurna/sensors/PZEM004TV30Sensor.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/code/espurna/sensors/BaseSensor.h b/code/espurna/sensors/BaseSensor.h index b1f8cd79..ed81adcb 100644 --- a/code/espurna/sensors/BaseSensor.h +++ b/code/espurna/sensors/BaseSensor.h @@ -95,8 +95,7 @@ class BaseSensor { switch (type(index)) { case MAGNITUDE_TEMPERATURE: return sensor::Unit::Celcius; - case MAGNITUDE_HUMIDITY: - case MAGNITUDE_POWER_FACTOR: + case MAGNITUDE_HUMIDITY: return sensor::Unit::Percentage; case MAGNITUDE_PRESSURE: return sensor::Unit::Hectopascal; diff --git a/code/espurna/sensors/PZEM004TV30Sensor.h b/code/espurna/sensors/PZEM004TV30Sensor.h index d13cb485..62f0a71b 100644 --- a/code/espurna/sensors/PZEM004TV30Sensor.h +++ b/code/espurna/sensors/PZEM004TV30Sensor.h @@ -402,7 +402,7 @@ class PZEM004TV30Sensor : public BaseEmonSensor { // - Power Factor: 2 bytes in 0.1% (we return %) _power_factor = take_2(); - _power_factor /= 10.0; + _power_factor /= 100.0; // - Alarms: 2 bytes, (NOT IMPLEMENTED) // XXX: it seems it can only be either 0xffff or 0 for ON and OFF respectively