Browse Source

Do not bypass current clamp measurement if relay is off

fastled
Xose Pérez 7 years ago
parent
commit
5b2a7a34ec
2 changed files with 6 additions and 4 deletions
  1. +1
    -0
      code/espurna/config/sensors.h
  2. +5
    -4
      code/espurna/emon.ino

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

@ -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
//--------------------------------------------------------------------------------


+ 5
- 4
code/espurna/emon.ino View File

@ -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;


Loading…
Cancel
Save