From a6569c884ac1a93604013f8222dc676240441f4a Mon Sep 17 00:00:00 2001 From: Marco Noord Date: Wed, 13 Jan 2016 17:19:59 +0100 Subject: [PATCH 1/2] Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output If no pullup is used, the reported usage will be too high because of the floating pin --- .../EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino b/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino index 30d18cf..144bc72 100644 --- a/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino +++ b/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino @@ -70,6 +70,10 @@ void setup() { // Fetch last known pulse count value from gw request(CHILD_ID, V_VAR1); + + // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output + // If no pullup is used, the reported usage will be too high because of the floating pin + digitalWrite(DIGITAL_INPUT_SENSOR,HIGH); attachInterrupt(INTERRUPT, onPulse, RISING); lastSend=millis(); From 9858cb19f0f3e5a08df9e9079b254837132439ad Mon Sep 17 00:00:00 2001 From: Marco Noord Date: Wed, 13 Jan 2016 17:57:48 +0100 Subject: [PATCH 2/2] Changed digitalwrite to pinmode, to make it more obvious what is happening here, and to offer more support within the Arduino API --- .../examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino b/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino index 144bc72..9b957de 100644 --- a/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino +++ b/libraries/MySensors/examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino @@ -73,7 +73,7 @@ void setup() // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output // If no pullup is used, the reported usage will be too high because of the floating pin - digitalWrite(DIGITAL_INPUT_SENSOR,HIGH); + pinMode(DIGITAL_INPUT_SENSOR,INPUT_PULLUP); attachInterrupt(INTERRUPT, onPulse, RISING); lastSend=millis();