Skip to content

Commit 668a5f6

Browse files
committed
Better "control" for determining if humiidty changes should fire off a transmission
1 parent 190479d commit 668a5f6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

libraries/MySensors/examples/SensebenderMicro/SensebenderMicro.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sha204_lib_return_codes.h>
1616
#include <sha204_library.h>
1717
#include <RunningAverage.h>
18-
#include <avr/power.h>
18+
//#include <avr/power.h>
1919

2020
// Define a static node address, remove if you want auto address assignment
2121
//#define NODE_ADDRESS 3
@@ -149,7 +149,7 @@ void loop() {
149149

150150
if ((measureCount == 5) && highfreq)
151151
{
152-
clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
152+
// clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
153153
highfreq = false;
154154
}
155155

@@ -182,21 +182,20 @@ void loop() {
182182
void sendTempHumidityMeasurements(bool force)
183183
{
184184
bool tx = force;
185-
185+
186186
si7021_env data = humiditySensor.getHumidityAndTemperature();
187-
float oldAvgHum = raHum.getAverage();
188187

189188
raHum.addValue(data.humidityPercent);
190189

191190
float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100);
192-
float diffHum = abs(oldAvgHum - raHum.getAverage());
191+
float diffHum = abs(lastHumidity - raHum.getAverage());
193192

194193
Serial.print(F("TempDiff :"));Serial.println(diffTemp);
195194
Serial.print(F("HumDiff :"));Serial.println(diffHum);
196195

197196
if (isnan(diffHum)) tx = true;
198197
if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true;
199-
if (diffHum >= HUMI_TRANSMIT_THRESHOLD) tx = true;
198+
if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true;
200199

201200
if (tx) {
202201
measureCount = 0;
@@ -246,7 +245,7 @@ void sendBattLevel(bool force)
246245
* Internal battery ADC measuring
247246
*
248247
*******************************************/
249-
long readVcc() {
248+
long readVcc() {/*
250249
// Read 1.1V reference against AVcc
251250
// set the reference to Vcc and the measurement to the internal 1.1V reference
252251
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
@@ -270,6 +269,7 @@ long readVcc() {
270269
271270
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
272271
return result; // Vcc in millivolts
272+
*/
273273
}
274274

275275
/****************************************************

0 commit comments

Comments
 (0)