Library for DHT11 DHT22 AM2302 and similar sensors. Now with value after decimal point for DHT22.
Dependents: Seeed_Grove_Temp_Humidity_Example DHT11_Temp_Humidity IoT_W5500_MQTT
Fork of DHT by
Diff: DHT.cpp
- Revision:
- 4:0667c68ef5e0
- Parent:
- 3:6937e130feca
- Child:
- 5:cce2105f7365
diff -r 6937e130feca -r 0667c68ef5e0 DHT.cpp --- a/DHT.cpp Sat May 28 11:11:34 2016 +0000 +++ b/DHT.cpp Sat Jan 07 21:58:20 2017 +0000 @@ -118,7 +118,7 @@ } // uncomment to see the checksum error if it exists - //printf(" 0x%02x + 0x%02x + 0x%02x + 0x%02x = 0x%02x \n", DHT_data[0], DHT_data[1], DHT_data[2], DHT_data[3], DHT_data[4]); + // printf(" 0x%02x + 0x%02x + 0x%02x + 0x%02x = 0x%02x \n", DHT_data[0], DHT_data[1], DHT_data[2], DHT_data[3], DHT_data[4]); data_valid = DHT_data[0] + DHT_data[1] + DHT_data[2] + DHT_data[3]; if (DHT_data[4] == data_valid) { _lastReadTime = currentTime; @@ -135,7 +135,7 @@ float DHT::CalcTemperature() { - int v; + float v; switch (_DHTtype) { case DHT11: @@ -207,8 +207,7 @@ float DHT::CalcHumidity() { - int v; - + float v; // needs to be float for DHT22 otherwise only zero after decimal point switch (_DHTtype) { case DHT11: v = DHT_data[0];