Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DHT by
Revision 1:6ddabfde1db6, committed 2016-02-05
- Comitter:
- gert_lauritsen
- Date:
- Fri Feb 05 10:03:57 2016 +0000
- Parent:
- 0:9b5b3200688f
- Commit message:
- There was an error in converting to float, trunkating the value
Changed in this revision
DHT.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9b5b3200688f -r 6ddabfde1db6 DHT.cpp --- 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; }