File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
examples/DhtTemperatureAndHumiditySensor Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 4646// Set this to the pin you connected the DHT's data pin to
4747#define DHT_DATA_PIN 3
4848
49- // Set this offset if the sensor has a permanent small offset to the real temperatures
49+ // Set this offset if the sensor has a permanent small offset to the real temperatures.
50+ // In Celsius degrees (as measured by the device)
5051#define SENSOR_TEMP_OFFSET 0
5152
5253// Sleep time between sensor updates (in milliseconds)
@@ -110,12 +111,15 @@ void loop()
110111 } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
111112 // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
112113 lastTemp = temperature;
114+
115+ // apply the offset before converting to something different than Celsius degrees
116+ temperature += SENSOR_TEMP_OFFSET;
117+
113118 if (!metric) {
114119 temperature = dht.toFahrenheit (temperature);
115120 }
116121 // Reset no updates counter
117122 nNoUpdatesTemp = 0 ;
118- temperature += SENSOR_TEMP_OFFSET;
119123 send (msgTemp.set (temperature, 1 ));
120124
121125 #ifdef MY_DEBUG
You can’t perform that action at this time.
0 commit comments