From b66bef4b4966f2514b2c4ade6b58bbc62a53a60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 23 Nov 2016 00:28:05 +0100 Subject: [PATCH] Using non-interrupt driven mode for HLW8012 --- code/src/pow.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/src/pow.ino b/code/src/pow.ino index e631e17b..0676ead5 100644 --- a/code/src/pow.ino +++ b/code/src/pow.ino @@ -105,7 +105,7 @@ void powSetup() { // * currentWhen is the value in sel_pin to select current sampling // * set use_interrupts to true to use interrupts to monitor pulse widths // * leave pulse_timeout to the default value, recommended when using interrupts - hlw8012.begin(POW_CF_PIN, POW_CF1_PIN, POW_SEL_PIN, POW_SEL_CURRENT, true); + hlw8012.begin(POW_CF_PIN, POW_CF1_PIN, POW_SEL_PIN, POW_SEL_CURRENT, false, 1000000); // These values are used to calculate current, voltage and power factors as per datasheet formula // These are the nominal values for the Sonoff POW resistors: @@ -116,6 +116,7 @@ void powSetup() { powRetrieveCalibration(); + /* static WiFiEventHandler e1 = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected& event) { powDettachInterrupts(); }); @@ -131,6 +132,7 @@ void powSetup() { static WiFiEventHandler e4 = WiFi.onSoftAPModeStationConnected([](const WiFiEventSoftAPModeStationConnected& event) { powAttachInterrupts(); }); + */ }