23
23
* Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
24
24
*
25
25
* DESCRIPTION
26
- * This sketch provides an example how to implement a humidity/temperature
27
- * sensor using DHT11/DHT-22.
26
+ * This sketch provides an example of how to implement a humidity/temperature
27
+ * sensor using a DHT11/DHT-22.
28
28
*
29
29
* For more information, please visit:
30
30
* http://www.mysensors.org/build/humidity
43
43
#include < MySensors.h>
44
44
#include < DHT.h>
45
45
46
- // Set the pin you connected the DHT's data pin to
46
+ // Set this to the pin you connected the DHT's data pin to
47
47
#define DHT_DATA_PIN 2
48
48
49
49
// Set this offset if the sensor has a permanent small offset to the real temperatures
54
54
static const uint64_t UPDATE_INTERVAL = 60000 ;
55
55
56
56
// Force sending an update of the temperature after n sensor reads, so a controller showing the
57
- // timestamp of the last update doesn't show something like 3 hours, in the unlikely case, that
57
+ // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
58
58
// the value didn't change since;
59
59
// i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
60
60
static const uint8_t FORCE_UPDATE_N_READS = 10 ;
@@ -75,7 +75,7 @@ DHT dht;
75
75
76
76
void presentation ()
77
77
{
78
- // Send the Sketch Version Information to the Gateway
78
+ // Send the sketch version information to the gateway
79
79
sendSketchInfo (" TemperatureAndHumidity" , " 1.1" );
80
80
81
81
// Register all sensors to gw (they will be created as child devices)
@@ -86,13 +86,14 @@ void presentation()
86
86
}
87
87
88
88
89
- void setup () {
89
+ void setup ()
90
+ {
90
91
dht.setup (DHT_DATA_PIN); // set data pin of DHT sensor
91
92
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod ()) {
92
93
Serial.println (" Warning: UPDATE_INTERVAL is smaller than supported by the sensor!" );
93
94
}
94
95
// Sleep for the time of the minimum sampling period to give the sensor time to power up
95
- // (otherwise, timeout erros might occure)
96
+ // (otherwise, timeout errors might occure for the first reading )
96
97
sleep (dht.getMinimumSamplingPeriod ());
97
98
}
98
99
0 commit comments