@@ -50,7 +50,6 @@ boolean metric = true;
50
50
MyMessage msgHum (CHILD_ID_HUM, V_HUM);
51
51
MyMessage msgTemp (CHILD_ID_TEMP, V_TEMP);
52
52
53
-
54
53
void setup ()
55
54
{
56
55
dht.setup (HUMIDITY_SENSOR_DIGITAL_PIN);
@@ -68,11 +67,11 @@ void presentation()
68
67
present (CHILD_ID_TEMP, S_TEMP);
69
68
}
70
69
71
-
72
70
void loop ()
73
71
{
74
72
delay (dht.getMinimumSamplingPeriod ());
75
-
73
+
74
+ // Fetch temperatures from DHT sensor
76
75
float temperature = dht.getTemperature ();
77
76
if (isnan (temperature)) {
78
77
Serial.println (" Failed reading temperature from DHT" );
@@ -82,21 +81,24 @@ void loop()
82
81
temperature = dht.toFahrenheit (temperature);
83
82
}
84
83
send (msgTemp.set (temperature, 1 ));
84
+ #if MY_DEBUG
85
85
Serial.print (" T: " );
86
86
Serial.println (temperature);
87
+ #endif
87
88
}
88
89
90
+ // Fetch humidity from DHT sensor
89
91
float humidity = dht.getHumidity ();
90
92
if (isnan (humidity)) {
91
93
Serial.println (" Failed reading humidity from DHT" );
92
94
} else if (humidity != lastHum) {
93
95
lastHum = humidity;
94
96
send (msgHum.set (humidity, 1 ));
97
+ #if MY_DEBUG
95
98
Serial.print (" H: " );
96
99
Serial.println (humidity);
100
+ #endif
97
101
}
98
-
102
+
99
103
sleep (SLEEP_TIME); // sleep a bit
100
104
}
101
-
102
-
0 commit comments