DHT sensor LIB
Dependents: DHT22tester LASS_LoRa_mbed TestingDHT22sensor_fork1 Test_sensor_DHT22
Fork of DHT by
Diff: DHT.cpp
- Revision:
- 1:6ddabfde1db6
- Parent:
- 0:9b5b3200688f
- Child:
- 2:cd93a537b2e7
--- a/DHT.cpp Mon Jul 09 19:47:43 2012 +0000 +++ b/DHT.cpp Fri Feb 05 10:03:57 2016 +0000 @@ -149,7 +149,7 @@ float DHT::CalcTemperature() { int v; - + float outvalue; switch (_DHTtype) { case DHT11: v = DHT_data[2]; @@ -158,10 +158,10 @@ v = DHT_data[2] & 0x7F; v *= 256; v += DHT_data[3]; - v /= 10; + outvalue=(float) v/10; if (DHT_data[2] & 0x80) - v *= -1; - return float(v); + outvalue *= -1; + return outvalue; } return 0; } @@ -215,7 +215,8 @@ float DHT::CalcHumidity() { int v; - + float outvalue; + switch (_DHTtype) { case DHT11: v = DHT_data[0]; @@ -224,8 +225,8 @@ v = DHT_data[0]; v *= 256; v += DHT_data[1]; - v /= 10; - return float(v); + outvalue=(float) v/10; + return outvalue; } return 0; }