ESP8266: Fix example compilation error (#932)
This commit is contained in:
committed by
Patrick Fallberg
parent
f5dce5b61b
commit
5164af7edc
@@ -63,7 +63,7 @@
|
|||||||
#define GAS_CO (1)
|
#define GAS_CO (1)
|
||||||
#define GAS_SMOKE (2)
|
#define GAS_SMOKE (2)
|
||||||
/*****************************Globals***********************************************/
|
/*****************************Globals***********************************************/
|
||||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
float Ro = 10000.0; // this has to be tuned 10K Ohm
|
float Ro = 10000.0; // this has to be tuned 10K Ohm
|
||||||
int val = 0; // variable to store the value coming from the sensor
|
int val = 0; // variable to store the value coming from the sensor
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 900000; // sleep time between reads (seconds * 1000 milliseconds)
|
uint32_t SLEEP_TIME = 900000; // sleep time between reads (seconds * 1000 milliseconds)
|
||||||
int oldBatteryPcnt = 0;
|
int oldBatteryPcnt = 0;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/**
|
||||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||||
* between your home built sensors/actuators and HA controller of choice.
|
* between your home built sensors/actuators and HA controller of choice.
|
||||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
#define CHILD_ID_AIQ 0
|
#define CHILD_ID_AIQ 0
|
||||||
#define AIQ_SENSOR_ANALOG_PIN 6
|
#define AIQ_SENSOR_ANALOG_PIN 6
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||||
|
|
||||||
float valAIQ =0.0;
|
float valAIQ =0.0;
|
||||||
float lastAIQ =0.0;
|
float lastAIQ =0.0;
|
||||||
@@ -78,12 +78,12 @@ void presentation()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
//unsigned long duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
//uint32_t duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
||||||
while(digitalRead(AIQ_SENSOR_ANALOG_PIN) == HIGH) {
|
while(digitalRead(AIQ_SENSOR_ANALOG_PIN) == HIGH) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
//wait for the pin to go HIGH and measure HIGH time
|
//wait for the pin to go HIGH and measure HIGH time
|
||||||
unsigned long duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
uint32_t duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
||||||
|
|
||||||
//Serial.print(duration/1000); Serial.println(" ms ");
|
//Serial.print(duration/1000); Serial.println(" ms ");
|
||||||
//from datasheet
|
//from datasheet
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#define CHILD_ID_DUST 0
|
#define CHILD_ID_DUST 0
|
||||||
#define DUST_SENSOR_ANALOG_PIN 1
|
#define DUST_SENSOR_ANALOG_PIN 1
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
int val = 0; // variable to store the value coming from the sensor
|
int val = 0; // variable to store the value coming from the sensor
|
||||||
float valDUST =0.0;
|
float valDUST =0.0;
|
||||||
|
|||||||
@@ -46,18 +46,18 @@
|
|||||||
#define DUST_SENSOR_DIGITAL_PIN_PM10 6
|
#define DUST_SENSOR_DIGITAL_PIN_PM10 6
|
||||||
#define DUST_SENSOR_DIGITAL_PIN_PM25 3
|
#define DUST_SENSOR_DIGITAL_PIN_PM25 3
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
int val = 0; // variable to store the value coming from the sensor
|
int val = 0; // variable to store the value coming from the sensor
|
||||||
float valDUSTPM25 =0.0;
|
float valDUSTPM25 =0.0;
|
||||||
float lastDUSTPM25 =0.0;
|
float lastDUSTPM25 =0.0;
|
||||||
float valDUSTPM10 =0.0;
|
float valDUSTPM10 =0.0;
|
||||||
float lastDUSTPM10 =0.0;
|
float lastDUSTPM10 =0.0;
|
||||||
unsigned long duration;
|
uint32_t duration;
|
||||||
unsigned long starttime;
|
uint32_t starttime;
|
||||||
unsigned long endtime;
|
uint32_t endtime;
|
||||||
unsigned long sampletime_ms = 30000;
|
uint32_t sampletime_ms = 30000;
|
||||||
unsigned long lowpulseoccupancy = 0;
|
uint32_t lowpulseoccupancy = 0;
|
||||||
float ratio = 0;
|
float ratio = 0;
|
||||||
long concentrationPM25 = 0;
|
long concentrationPM25 = 0;
|
||||||
long concentrationPM10 = 0;
|
long concentrationPM10 = 0;
|
||||||
@@ -88,7 +88,7 @@ void presentation()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
//get PM 2.5 density of particles over 2.5 μm.
|
//get PM 2.5 density of particles over 2.5 µm.
|
||||||
concentrationPM25=(long)getPM(DUST_SENSOR_DIGITAL_PIN_PM25);
|
concentrationPM25=(long)getPM(DUST_SENSOR_DIGITAL_PIN_PM25);
|
||||||
Serial.print("PM25: ");
|
Serial.print("PM25: ");
|
||||||
Serial.println(concentrationPM25);
|
Serial.println(concentrationPM25);
|
||||||
@@ -99,7 +99,7 @@ void loop()
|
|||||||
lastDUSTPM25 = ceil(concentrationPM25);
|
lastDUSTPM25 = ceil(concentrationPM25);
|
||||||
}
|
}
|
||||||
|
|
||||||
//get PM 1.0 - density of particles over 1 μm.
|
//get PM 1.0 - density of particles over 1 µm.
|
||||||
concentrationPM10=getPM(DUST_SENSOR_DIGITAL_PIN_PM10);
|
concentrationPM10=getPM(DUST_SENSOR_DIGITAL_PIN_PM10);
|
||||||
Serial.print("PM10: ");
|
Serial.print("PM10: ");
|
||||||
Serial.println(concentrationPM10);
|
Serial.println(concentrationPM10);
|
||||||
|
|||||||
@@ -51,17 +51,17 @@
|
|||||||
#define MAX_WATT 10000 // Max watt value to report. This filetrs outliers.
|
#define MAX_WATT 10000 // Max watt value to report. This filetrs outliers.
|
||||||
#define CHILD_ID 1 // Id of the sensor child
|
#define CHILD_ID 1 // Id of the sensor child
|
||||||
|
|
||||||
unsigned long SEND_FREQUENCY =
|
uint32_t SEND_FREQUENCY =
|
||||||
20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
|
20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
|
||||||
double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour
|
double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour
|
||||||
bool pcReceived = false;
|
bool pcReceived = false;
|
||||||
volatile unsigned long pulseCount = 0;
|
volatile uint32_t pulseCount = 0;
|
||||||
volatile unsigned long lastBlink = 0;
|
volatile uint32_t lastBlink = 0;
|
||||||
volatile unsigned long watt = 0;
|
volatile uint32_t watt = 0;
|
||||||
unsigned long oldPulseCount = 0;
|
uint32_t oldPulseCount = 0;
|
||||||
unsigned long oldWatt = 0;
|
uint32_t oldWatt = 0;
|
||||||
double oldKwh;
|
double oldKwh;
|
||||||
unsigned long 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);
|
||||||
@@ -91,7 +91,7 @@ void presentation()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long now = millis();
|
uint32_t now = millis();
|
||||||
// Only send values at a maximum frequency or woken up from sleep
|
// Only send values at a maximum frequency or woken up from sleep
|
||||||
bool sendTime = now - lastSend > SEND_FREQUENCY;
|
bool sendTime = now - lastSend > SEND_FREQUENCY;
|
||||||
if (pcReceived && (SLEEP_MODE || sendTime)) {
|
if (pcReceived && (SLEEP_MODE || sendTime)) {
|
||||||
@@ -99,7 +99,7 @@ void loop()
|
|||||||
if (!SLEEP_MODE && watt != oldWatt) {
|
if (!SLEEP_MODE && watt != oldWatt) {
|
||||||
// Check that we dont get unresonable large watt value.
|
// Check that we dont get unresonable large watt value.
|
||||||
// could hapen when long wraps or false interrupt triggered
|
// could hapen when long wraps or false interrupt triggered
|
||||||
if (watt<((unsigned long)MAX_WATT)) {
|
if (watt<((uint32_t)MAX_WATT)) {
|
||||||
send(wattMsg.set(watt)); // Send watt value to gw
|
send(wattMsg.set(watt)); // Send watt value to gw
|
||||||
}
|
}
|
||||||
Serial.print("Watt:");
|
Serial.print("Watt:");
|
||||||
@@ -142,8 +142,8 @@ void receive(const MyMessage &message)
|
|||||||
void onPulse()
|
void onPulse()
|
||||||
{
|
{
|
||||||
if (!SLEEP_MODE) {
|
if (!SLEEP_MODE) {
|
||||||
unsigned long newBlink = micros();
|
uint32_t newBlink = micros();
|
||||||
unsigned long interval = newBlink-lastBlink;
|
uint32_t interval = newBlink-lastBlink;
|
||||||
if (interval<10000L) { // Sometimes we get interrupt on RISING
|
if (interval<10000L) { // Sometimes we get interrupt on RISING
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,4 @@ void onPulse()
|
|||||||
lastBlink = newBlink;
|
lastBlink = newBlink;
|
||||||
}
|
}
|
||||||
pulseCount++;
|
pulseCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
#define CHILD_ID_LIGHT 0
|
#define CHILD_ID_LIGHT 0
|
||||||
#define LIGHT_SENSOR_ANALOG_PIN 0
|
#define LIGHT_SENSOR_ANALOG_PIN 0
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||||
|
|
||||||
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
|
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
|
||||||
int lastLightLevel;
|
int lastLightLevel;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// Global Vars
|
// Global Vars
|
||||||
unsigned long SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
|
||||||
bool metric = true;
|
bool metric = true;
|
||||||
long randNumber;
|
long randNumber;
|
||||||
|
|
||||||
@@ -721,7 +721,7 @@ void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is called when a new time value was received
|
// This is called when a new time value was received
|
||||||
void receiveTime(unsigned long controllerTime)
|
void receiveTime(uint32_t controllerTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
Serial.print("Time value received: ");
|
Serial.print("Time value received: ");
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
||||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
|
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
|
||||||
#define CHILD_ID 1 // Id of the sensor child
|
#define CHILD_ID 1 // Id of the sensor child
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
#include <MySensors.h>
|
#include <MySensors.h>
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
||||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
|
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
|
||||||
#define CHILD_ID 1 // Id of the sensor child
|
#define CHILD_ID 1 // Id of the sensor child
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
|
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
|
||||||
float lastPH;
|
float lastPH;
|
||||||
bool receivedConfig = false;
|
bool receivedConfig = false;
|
||||||
bool metric = true;
|
bool metric = true;
|
||||||
|
|||||||
@@ -432,8 +432,8 @@ static const uint8_t reset_buffer[32] = {
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
// Delay startup a bit for serial consoles to catch up
|
// Delay startup a bit for serial consoles to catch up
|
||||||
unsigned long enter = hwMillis();
|
uint32_t enter = hwMillis();
|
||||||
while (hwMillis() - enter < (unsigned long)500);
|
while (hwMillis() - enter < (uint32_t)500);
|
||||||
#ifdef USE_SOFT_SIGNING
|
#ifdef USE_SOFT_SIGNING
|
||||||
// initialize pseudo-RNG
|
// initialize pseudo-RNG
|
||||||
hwRandomNumberInit();
|
hwRandomNumberInit();
|
||||||
@@ -530,8 +530,8 @@ static bool generate_random_data(uint8_t* data, size_t sz)
|
|||||||
#if defined(USE_SOFT_SIGNING) && ! defined(MY_HW_HAS_GETENTROPY)
|
#if defined(USE_SOFT_SIGNING) && ! defined(MY_HW_HAS_GETENTROPY)
|
||||||
for (size_t i = 0; i < sz; i++) {
|
for (size_t i = 0; i < sz; i++) {
|
||||||
data[i] = random(256) ^ micros();
|
data[i] = random(256) ^ micros();
|
||||||
unsigned long enter = hwMillis();
|
uint32_t enter = hwMillis();
|
||||||
while (hwMillis() - enter < (unsigned long)2);
|
while (hwMillis() - enter < (uint32_t)2);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
#elif defined(USE_SOFT_SIGNING) && defined(MY_HW_HAS_GETENTROPY)
|
#elif defined(USE_SOFT_SIGNING) && defined(MY_HW_HAS_GETENTROPY)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
#define CHILD_ID 0
|
#define CHILD_ID 0
|
||||||
|
|
||||||
MyMessage msg(CHILD_ID, V_LEVEL);
|
MyMessage msg(CHILD_ID, V_LEVEL);
|
||||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||||
|
|
||||||
long buffer[NUM_READS];
|
long buffer[NUM_READS];
|
||||||
int idx;
|
int idx;
|
||||||
|
|||||||
@@ -51,11 +51,11 @@
|
|||||||
|
|
||||||
#define CHILD_ID_UV 0
|
#define CHILD_ID_UV 0
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
uint32_t SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||||
|
|
||||||
MyMessage uvMsg(CHILD_ID_UV, V_UV);
|
MyMessage uvMsg(CHILD_ID_UV, V_UV);
|
||||||
|
|
||||||
unsigned long lastSend =0;
|
uint32_t lastSend =0;
|
||||||
float uvIndex;
|
float uvIndex;
|
||||||
float lastUV = -1;
|
float lastUV = -1;
|
||||||
uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
|
uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
|
||||||
@@ -72,7 +72,7 @@ void presentation()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long currentTime = millis();
|
uint32_t currentTime = millis();
|
||||||
|
|
||||||
uint16_t uv = analogRead(UV_SENSOR_ANALOG_PIN);// Get UV value
|
uint16_t uv = analogRead(UV_SENSOR_ANALOG_PIN);// Get UV value
|
||||||
if (uv>1170) {
|
if (uv>1170) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#define VIBRATION_SENSOR_DIGITAL_PIN 3
|
#define VIBRATION_SENSOR_DIGITAL_PIN 3
|
||||||
#define SensorLED 13
|
#define SensorLED 13
|
||||||
|
|
||||||
unsigned long SLEEP_TIME = 10*1000; // Sleep time between reads (in seconds)
|
uint32_t SLEEP_TIME = 10*1000; // Sleep time between reads (in seconds)
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
int val = 0; // variable to store the value coming from the sensor
|
int val = 0; // variable to store the value coming from the sensor
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
#define CHILD_ID 1 // Id of the sensor child
|
#define CHILD_ID 1 // Id of the sensor child
|
||||||
|
|
||||||
unsigned long SEND_FREQUENCY =
|
uint32_t SEND_FREQUENCY =
|
||||||
30000; // Minimum time between send (in milliseconds). We don't want to spam the gateway.
|
30000; // Minimum time between send (in milliseconds). We don't want to spam the gateway.
|
||||||
|
|
||||||
MyMessage flowMsg(CHILD_ID,V_FLOW);
|
MyMessage flowMsg(CHILD_ID,V_FLOW);
|
||||||
@@ -64,17 +64,17 @@ MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
|
|||||||
|
|
||||||
double ppl = ((double)PULSE_FACTOR)/1000; // Pulses per liter
|
double ppl = ((double)PULSE_FACTOR)/1000; // Pulses per liter
|
||||||
|
|
||||||
volatile unsigned long pulseCount = 0;
|
volatile uint32_t pulseCount = 0;
|
||||||
volatile unsigned long lastBlink = 0;
|
volatile uint32_t lastBlink = 0;
|
||||||
volatile double flow = 0;
|
volatile double flow = 0;
|
||||||
bool pcReceived = false;
|
bool pcReceived = false;
|
||||||
unsigned long oldPulseCount = 0;
|
uint32_t oldPulseCount = 0;
|
||||||
unsigned long newBlink = 0;
|
uint32_t newBlink = 0;
|
||||||
double oldflow = 0;
|
double oldflow = 0;
|
||||||
double volume =0;
|
double volume =0;
|
||||||
double oldvolume =0;
|
double oldvolume =0;
|
||||||
unsigned long lastSend =0;
|
uint32_t lastSend =0;
|
||||||
unsigned long lastPulse =0;
|
uint32_t lastPulse =0;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@@ -102,7 +102,7 @@ void presentation()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long currentTime = millis();
|
uint32_t currentTime = millis();
|
||||||
|
|
||||||
// Only send values at a maximum frequency or woken up from sleep
|
// Only send values at a maximum frequency or woken up from sleep
|
||||||
if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY)) {
|
if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY)) {
|
||||||
@@ -122,7 +122,7 @@ void loop()
|
|||||||
|
|
||||||
// Check that we dont get unresonable large flow value.
|
// Check that we dont get unresonable large flow value.
|
||||||
// could hapen when long wraps or false interrupt triggered
|
// could hapen when long wraps or false interrupt triggered
|
||||||
if (flow<((unsigned long)MAX_FLOW)) {
|
if (flow<((uint32_t)MAX_FLOW)) {
|
||||||
send(flowMsg.set(flow, 2)); // Send flow value to gw
|
send(flowMsg.set(flow, 2)); // Send flow value to gw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ void loop()
|
|||||||
void receive(const MyMessage &message)
|
void receive(const MyMessage &message)
|
||||||
{
|
{
|
||||||
if (message.type==V_VAR1) {
|
if (message.type==V_VAR1) {
|
||||||
unsigned long gwPulseCount=message.getULong();
|
uint32_t gwPulseCount=message.getULong();
|
||||||
pulseCount += gwPulseCount;
|
pulseCount += gwPulseCount;
|
||||||
flow=oldflow=0;
|
flow=oldflow=0;
|
||||||
Serial.print("Received last pulse count from gw:");
|
Serial.print("Received last pulse count from gw:");
|
||||||
@@ -172,8 +172,8 @@ void receive(const MyMessage &message)
|
|||||||
void onPulse()
|
void onPulse()
|
||||||
{
|
{
|
||||||
if (!SLEEP_MODE) {
|
if (!SLEEP_MODE) {
|
||||||
unsigned long newBlink = micros();
|
uint32_t newBlink = micros();
|
||||||
unsigned long interval = newBlink-lastBlink;
|
uint32_t interval = newBlink-lastBlink;
|
||||||
|
|
||||||
if (interval!=0) {
|
if (interval!=0) {
|
||||||
lastPulse = millis();
|
lastPulse = millis();
|
||||||
|
|||||||
Reference in New Issue
Block a user