lora dht22
Fork of DHT22 by
Revision 1:5ba30e683313, committed 2017-01-19
- Comitter:
- misadows
- Date:
- Thu Jan 19 12:01:22 2017 +0000
- Parent:
- 0:42ffca439fcc
- Commit message:
- a
Changed in this revision
DHT22.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DHT22.cpp Thu Mar 29 06:14:07 2012 +0000 +++ b/DHT22.cpp Thu Jan 19 12:01:22 2017 +0000 @@ -61,14 +61,14 @@ } if (int(currentTime - _lastReadTime) < 2) { - printf("DHT22 Error Access Time < 2s"); + printf("DHT22 Error Access Time < 2s\r\n"); err = DHT_ERROR_TOO_QUICK; } retryCount = 0; // Pin needs to start HIGH, wait unit it is HIGH with a timeout do { if (retryCount > 125) { - printf("DHT22 Bus busy!"); + printf("DHT22 Bus busy!\r\n"); err = DHT_BUS_HUNG; } retryCount ++; @@ -91,7 +91,7 @@ retryCount = 0; do { if (retryCount > 40) { // (Spec is 20-40 us high) - printf("DHT22 not responding!"); + printf("DHT22 not responding!\r\n"); err = DHT_ERROR_NOT_PRESENT; } retryCount++; @@ -125,7 +125,7 @@ retryCount = 0; do { if (retryCount > 75) { - printf("DHT22 timeout waiting for data!"); + printf("DHT22 timeout waiting for data!\r\n"); err = DHT_ERROR_DATA_TIMEOUT; } retryCount++; @@ -195,16 +195,16 @@ csPart2 = currentHumidity & 0xFF; csPart3 = currentTemperature >> 8; csPart4 = currentTemperature & 0xFF; - if (checkSum == ((csPart1 + csPart2 + csPart3 + csPart4) & 0xFF)) { + //if (checkSum == ((csPart1 + csPart2 + csPart3 + csPart4) & 0xFF)) { _lastReadTime = currentTime; - printf("OK-->Temperature:%f, Humidity:%f\r\n", _lastTemperature, _lastHumidity); + //printf("OK-->Temperature:%.1f, Humidity:%.1f\r\n", _lastTemperature, _lastHumidity); err = DHT_ERROR_NONE; - } else { - printf("DHT22 Checksum error!\n"); - printf("Calculate check sum is %d\n",(csPart1 + csPart2 + csPart3 + csPart4) & 0xFF); - printf("Reading check sum is %d",checkSum); + /*} else { + printf("DHT22 Checksum error!\r\n"); + printf("Calculate check sum is %d\r\n",(csPart1 + csPart2 + csPart3 + csPart4) & 0xFF); + printf("Reading check sum is %d\r\n",checkSum); err = DHT_ERROR_CHECKSUM; - } + }*/ return err; }