40
40
// When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
41
41
// Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement
42
42
43
+ // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with
44
+ // TEMP_TRANSMIT_THRESHOLD for temperature threshold.
45
+ #define HUMI_TRANSMIT_THRESHOLD 0.5
46
+ #define TEMP_TRANSMIT_THRESHOLD 0.5
47
+
43
48
// Pin definitions
44
49
#define TEST_PIN A0
45
50
#define LED_PIN A2
@@ -73,7 +78,6 @@ int lastHumidity = -100;
73
78
long lastBattery = -100 ;
74
79
75
80
RunningAverage raHum (AVERAGES);
76
- RunningAverage raTemp (AVERAGES);
77
81
78
82
/* ***************************************************
79
83
*
@@ -109,6 +113,20 @@ void setup() {
109
113
gw.begin (NULL ,AUTO,false );
110
114
#endif
111
115
116
+ // --- following code will heat up the sensor element, and wait until the temperature is
117
+ // within 0.3 degrees celcius of the initial temperature (measured at startup).
118
+ // This is to try and burn away residue humidity from manufacturing process.
119
+ int temperature = humiditySensor.getCelsiusHundredths ();
120
+
121
+ humiditySensor.setHeater (true );
122
+ delay (500 );
123
+ humiditySensor.setHeater (false );
124
+
125
+ int t = 0 ;
126
+ do {
127
+ t = humiditySensor.getCelsiusHundredths () - temperature;
128
+ } while (abs (t) >30 );
129
+ // ---
112
130
digitalWrite (LED_PIN, LOW);
113
131
114
132
humiditySensor.begin ();
@@ -123,10 +141,10 @@ void setup() {
123
141
gw.present (BATT_SENSOR, S_POWER);
124
142
#endif
125
143
144
+
126
145
isMetric = gw.getConfig ().isMetric ;
127
146
Serial.print (F (" isMetric: " )); Serial.println (isMetric);
128
147
raHum.clear ();
129
- raTemp.clear ();
130
148
sendTempHumidityMeasurements (false );
131
149
sendBattLevel (false );
132
150
}
@@ -179,10 +197,8 @@ void sendTempHumidityMeasurements(bool force)
179
197
bool tx = force;
180
198
181
199
si7021_env data = humiditySensor.getHumidityAndTemperature ();
182
- float oldAvgTemp = raTemp.getAverage ();
183
200
float oldAvgHum = raHum.getAverage ();
184
201
185
- raTemp.addValue (data.celsiusHundredths );
186
202
raHum.addValue (data.humidityPercent );
187
203
188
204
float diffTemp = abs (lastTemperature - data.celsiusHundredths /100 );
@@ -192,8 +208,8 @@ void sendTempHumidityMeasurements(bool force)
192
208
Serial.print (F (" HumDiff :" ));Serial.println (diffHum);
193
209
194
210
if (isnan (diffTemp)) tx = true ;
195
- if (diffTemp > 0.3 ) tx = true ;
196
- if (diffHum >= 0.5 ) tx = true ;
211
+ if (diffTemp > TEMP_TRANSMIT_THRESHOLD ) tx = true ;
212
+ if (diffHum >= HUMI_TRANSMIT_THRESHOLD ) tx = true ;
197
213
198
214
if (tx) {
199
215
measureCount = 0 ;
0 commit comments