Word corrections (#1114)
* Word corrections * Removed an enter Thanks @flopp999 !
This commit is contained in:
committed by
Mikael Falkvidd
parent
bb7766197c
commit
6c9be97fa3
@@ -19,18 +19,18 @@
|
|||||||
*******************************
|
*******************************
|
||||||
*
|
*
|
||||||
* REVISION HISTORY
|
* REVISION HISTORY
|
||||||
* Version 1.0 - Henrik EKblad
|
* Version 1.0 - Henrik Ekblad
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* This sketch provides an example how to implement a distance sensor using HC-SR04
|
* This sketch provides an example how to implement a LM393 PCB
|
||||||
* Use this sensor to measure KWH and Watt of your house meeter
|
* Use this sensor to measure kWh and Watt of your house meter
|
||||||
* You need to set the correct pulsefactor of your meeter (blinks per KWH).
|
* You need to set the correct pulsefactor of your meter (blinks per kWh).
|
||||||
* The sensor starts by fetching current KWH value from gateway.
|
* The sensor starts by fetching current kWh value from gateway.
|
||||||
* Reports both KWH and Watt back to gateway.
|
* Reports both kWh and Watt back to gateway.
|
||||||
*
|
*
|
||||||
* Unfortunately millis() won't increment when the Arduino is in
|
* Unfortunately millis() won't increment when the Arduino is in
|
||||||
* sleepmode. So we cannot make this sensor sleep if we also want
|
* sleepmode. So we cannot make this sensor sleep if we also want
|
||||||
* to calculate/report watt-number.
|
* to calculate/report watt value.
|
||||||
* http://www.mysensors.org/build/pulse_power
|
* http://www.mysensors.org/build/pulse_power
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@
|
|||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
|
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
|
||||||
#define PULSE_FACTOR 1000 // Number of blinks per KWH of your meeter
|
#define PULSE_FACTOR 1000 // Number of blinks per of your meter
|
||||||
#define SLEEP_MODE false // Watt-value can only be reported when sleep mode is false.
|
#define SLEEP_MODE false // Watt value can only be reported when sleep mode is false.
|
||||||
#define MAX_WATT 10000 // Max watt value to report. This filters outliers.
|
#define MAX_WATT 10000 // Max watt value to report. This filters outliers.
|
||||||
#define CHILD_ID 1 // Id of the sensor child
|
#define CHILD_ID 1 // Id of the sensor child
|
||||||
|
|
||||||
@@ -60,10 +60,10 @@ volatile uint32_t lastBlink = 0;
|
|||||||
volatile uint32_t watt = 0;
|
volatile uint32_t watt = 0;
|
||||||
uint32_t oldPulseCount = 0;
|
uint32_t oldPulseCount = 0;
|
||||||
uint32_t oldWatt = 0;
|
uint32_t oldWatt = 0;
|
||||||
double oldKwh;
|
double oldkWh;
|
||||||
uint32_t lastSend;
|
uint32_t lastSend;
|
||||||
MyMessage wattMsg(CHILD_ID,V_WATT);
|
MyMessage wattMsg(CHILD_ID,V_WATT);
|
||||||
MyMessage kwhMsg(CHILD_ID,V_KWH);
|
MyMessage kWhMsg(CHILD_ID,V_KWH);
|
||||||
MyMessage pcMsg(CHILD_ID,V_VAR1);
|
MyMessage pcMsg(CHILD_ID,V_VAR1);
|
||||||
|
|
||||||
|
|
||||||
@@ -107,19 +107,19 @@ void loop()
|
|||||||
oldWatt = watt;
|
oldWatt = watt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pulse cout has changed
|
// Pulse count value has changed
|
||||||
if (pulseCount != oldPulseCount) {
|
if (pulseCount != oldPulseCount) {
|
||||||
send(pcMsg.set(pulseCount)); // Send pulse count value to gw
|
send(pcMsg.set(pulseCount)); // Send pulse count value to gw
|
||||||
double kwh = ((double)pulseCount/((double)PULSE_FACTOR));
|
double kWh = ((double)pulseCount/((double)PULSE_FACTOR));
|
||||||
oldPulseCount = pulseCount;
|
oldPulseCount = pulseCount;
|
||||||
if (kwh != oldKwh) {
|
if (kWh != oldkWh) {
|
||||||
send(kwhMsg.set(kwh, 4)); // Send kwh value to gw
|
send(kWhMsg.set(kWh, 4)); // Send kWh value to gw
|
||||||
oldKwh = kwh;
|
oldkWh = kWh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastSend = now;
|
lastSend = now;
|
||||||
} else if (sendTime && !pcReceived) {
|
} else if (sendTime && !pcReceived) {
|
||||||
// No count received. Try requesting it again
|
// No pulse count value received. Try requesting it again
|
||||||
request(CHILD_ID, V_VAR1);
|
request(CHILD_ID, V_VAR1);
|
||||||
lastSend=now;
|
lastSend=now;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ void receive(const MyMessage &message)
|
|||||||
{
|
{
|
||||||
if (message.type==V_VAR1) {
|
if (message.type==V_VAR1) {
|
||||||
pulseCount = oldPulseCount = message.getLong();
|
pulseCount = oldPulseCount = message.getLong();
|
||||||
Serial.print("Received last pulse count from gw:");
|
Serial.print("Received last pulse count value from gw:");
|
||||||
Serial.println(pulseCount);
|
Serial.println(pulseCount);
|
||||||
pcReceived = true;
|
pcReceived = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user