From 5b2a7a34ec1f4411fd40f30b244b9b588e5029b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 2 Feb 2017 12:01:18 +0100 Subject: [PATCH] Do not bypass current clamp measurement if relay is off --- code/espurna/config/sensors.h | 1 + code/espurna/emon.ino | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index 18ea50d0..2070ee97 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -37,6 +37,7 @@ //-------------------------------------------------------------------------------- // Custom current sensor // Check http://tinkerman.cat/your-laundry-is-done/ +// Check http://tinkerman.cat/power-monitoring-sonoff-th-adc121/ // Enable support by passing ENABLE_EMON=1 build flag //-------------------------------------------------------------------------------- diff --git a/code/espurna/emon.ino b/code/espurna/emon.ino index d866fc5f..81109430 100644 --- a/code/espurna/emon.ino +++ b/code/espurna/emon.ino @@ -144,13 +144,14 @@ void powerMonitorLoop() { if (millis() > next_measurement) { // Safety check: do not read current if relay is OFF - if (!relayStatus(0)) { - _current = 0; - } else { + // You could be monitoring another line with the current clamp... + //if (!relayStatus(0)) { + // _current = 0; + //} else { _current = emon.getCurrent(EMON_SAMPLES); _current -= EMON_CURRENT_OFFSET; if (_current < 0) _current = 0; - } + //} if (measurements == 0) { max = min = _current;