diff --git a/code/espurna/sensor.cpp b/code/espurna/sensor.cpp index e8dc14e2..4dfb6a2e 100644 --- a/code/espurna/sensor.cpp +++ b/code/espurna/sensor.cpp @@ -1491,9 +1491,6 @@ void _sensorLoad() { sensor->setSEL(getSetting("snsHlw8012SelGPIO", HLW8012_SEL_PIN)); sensor->setCF(getSetting("snsHlw8012CfGPIO", HLW8012_CF_PIN)); sensor->setCF1(getSetting("snsHlw8012Cf1GPIO", HLW8012_CF1_PIN)); - sensor->setCurrentRatio(HLW8012_CURRENT_RATIO); - sensor->setVoltageRatio(HLW8012_VOLTAGE_RATIO); - sensor->setPowerRatio(HLW8012_POWER_RATIO); sensor->setSELCurrent(HLW8012_SEL_CURRENT); _sensors.push_back(sensor); } diff --git a/code/espurna/sensors/HLW8012Sensor.h b/code/espurna/sensors/HLW8012Sensor.h index bced2648..1f1025c7 100644 --- a/code/espurna/sensors/HLW8012Sensor.h +++ b/code/espurna/sensors/HLW8012Sensor.h @@ -142,6 +142,11 @@ class HLW8012Sensor : public BaseEmonSensor { // * The VOLTAGE_RESISTOR_DOWNSTREAM is the 1kOhm resistor in the voltage divider that feeds the V2P pin in the HLW8012 _hlw8012->setResistors(HLW8012_CURRENT_R, HLW8012_VOLTAGE_R_UP, HLW8012_VOLTAGE_R_DOWN); + // Also, adjust with ratio values that could be set in hardware profile + if (HLW8012_CURRENT_RATIO > 0.0) _hlw8012->setCurrentMultiplier(HLW8012_CURRENT_RATIO); + if (HLW8012_VOLTAGE_RATIO > 0.0) _hlw8012->setVoltageMultiplier(HLW8012_VOLTAGE_RATIO); + if (HLW8012_POWER_RATIO > 0.0) _hlw8012->setPowerMultiplier(HLW8012_POWER_RATIO); + // Handle interrupts #if HLW8012_USE_INTERRUPTS && (!HLW8012_WAIT_FOR_WIFI) _enableInterrupts(false);