Fork of DHT repo with checksum fixes.
Fork of DHT by
Revision 2:e7b0a41eecac, committed 2017-11-12
- Comitter:
- geekylou
- Date:
- Sun Nov 12 16:28:40 2017 +0000
- Parent:
- 1:932d451474dc
- Commit message:
- Fix checksum calculations.
Changed in this revision
DHT.cpp | Show annotated file Show diff for this revision Revisions of this file |
DHT.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DHT.cpp Sat Apr 19 18:05:38 2014 +0000 +++ b/DHT.cpp Sun Nov 12 16:28:40 2017 +0000 @@ -91,10 +91,10 @@ //humidity = bits[0]; //temperature = bits[2]; - uint8_t sum = bits[0] + bits[2]; + uint8_t sum = bits[0] + bits[1] + bits[2] + bits[3]; if(bits[4] != sum)return DHTLIB_ERROR_CHECKSUM; - + return DHTLIB_OK; } float DHT::ReadTemperature() { @@ -116,7 +116,7 @@ return 0; } -int DHT::ReadHumidity() { +float DHT::ReadHumidity() { //int v; switch (_DHTtype) {
--- a/DHT.h Sat Apr 19 18:05:38 2014 +0000 +++ b/DHT.h Sun Nov 12 16:28:40 2017 +0000 @@ -33,7 +33,7 @@ ~DHT(); uint8_t bits[5]; int readData(void); - int ReadHumidity(void); + float ReadHumidity(void); float ReadTemperature(void); int humidity; float temperature;