From e2769e3a7e279440134188fdfe19052ccdb7383e Mon Sep 17 00:00:00 2001 From: Alex Gutowski Date: Mon, 28 Oct 2013 00:54:06 -0500 Subject: [PATCH 1/5] Updates idDHT11.cpp to differentiate between timeouts Creates three different error codes instead of a single code for three timeout possibilities. --- idDHT11.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/idDHT11.cpp b/idDHT11.cpp index b67ed01..4f03667 100644 --- a/idDHT11.cpp +++ b/idDHT11.cpp @@ -67,7 +67,7 @@ void idDHT11::isrCallback() { int delta = (newUs-us); us = newUs; if (delta>6000) { - status = IDDHTLIB_ERROR_TIMEOUT; + status = IDDHTLIB_ERROR_ISR_TIMEOUT; state = STOPPED; detachInterrupt(intNumber); return; @@ -81,7 +81,7 @@ void idDHT11::isrCallback() { state = DATA; } else { detachInterrupt(intNumber); - status = IDDHTLIB_ERROR_TIMEOUT; + status = IDDHTLIB_ERROR_RESPONSE_TIMEOUT; state = STOPPED; } break; @@ -114,7 +114,7 @@ void idDHT11::isrCallback() { } else cnt--; } else { detachInterrupt(intNumber); - status = IDDHTLIB_ERROR_TIMEOUT; + status = IDDHTLIB_ERROR_DATA_TIMEOUT; state = STOPPED; } break; @@ -176,4 +176,4 @@ double idDHT11::getDewPointSlow() { double T = log(VP/0.61078); // temp var return (241.88 * T) / (17.558-T); } -// EOF \ No newline at end of file +// EOF From e73b4fb665c229415dc690597fc2cef870a070d7 Mon Sep 17 00:00:00 2001 From: Alex Gutowski Date: Mon, 28 Oct 2013 00:56:17 -0500 Subject: [PATCH 2/5] Updates idDHT11.h to differentiate between timeouts Creates three different error codes instead of a single code for three timeout possibilities. --- idDHT11.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/idDHT11.h b/idDHT11.h index 384cc44..ea39613 100644 --- a/idDHT11.h +++ b/idDHT11.h @@ -21,17 +21,19 @@ #define IDDHT11LIB_VERSION "0.1" // state codes -#define IDDHTLIB_OK 0 +#define IDDHTLIB_OK 0 #define IDDHTLIB_ACQUIRING 1 #define IDDHTLIB_ACQUIRED 2 -#define IDDHTLIB_RESPONSE_OK 3 +#define IDDHTLIB_RESPONSE_OK 3 // error codes #define IDDHTLIB_ERROR_CHECKSUM -1 -#define IDDHTLIB_ERROR_TIMEOUT -2 -#define IDDHTLIB_ERROR_ACQUIRING -3 -#define IDDHTLIB_ERROR_DELTA -4 -#define IDDHTLIB_ERROR_NOTSTARTED -5 +#define IDDHTLIB_ERROR_ISR_TIMEOUT -2 +#define IDDHTLIB_ERROR_RESPONSE_TIMEOUT -3 +#define IDDHTLIB_ERROR_DATA_TIMEOUT -4 +#define IDDHTLIB_ERROR_ACQUIRING -5 +#define IDDHTLIB_ERROR_DELTA -6 +#define IDDHTLIB_ERROR_NOTSTARTED -7 #define IDDHT11_CHECK_STATE if(state == STOPPED) \ return status; \ @@ -71,4 +73,4 @@ private: volatile float hum; volatile float temp; }; -#endif // idDHT11_H__ \ No newline at end of file +#endif // idDHT11_H__ From e15e40b20d4b0a5715af58f14901b91e7ec53bc9 Mon Sep 17 00:00:00 2001 From: Alex Gutowski Date: Mon, 28 Oct 2013 00:58:24 -0500 Subject: [PATCH 3/5] Adds timeout error messages for each new error code --- examples/idDHT11_Lib_example/idDHT11_Lib_example.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/idDHT11_Lib_example/idDHT11_Lib_example.ino b/examples/idDHT11_Lib_example/idDHT11_Lib_example.ino index b043514..05006b6 100644 --- a/examples/idDHT11_Lib_example/idDHT11_Lib_example.ino +++ b/examples/idDHT11_Lib_example/idDHT11_Lib_example.ino @@ -47,8 +47,14 @@ void loop() case IDDHTLIB_ERROR_CHECKSUM: Serial.println("Error\n\r\tChecksum error"); break; - case IDDHTLIB_ERROR_TIMEOUT: - Serial.println("Error\n\r\tTime out error"); + case IDDHTLIB_ERROR_ISR_TIMEOUT: + Serial.println("Error\n\r\tISR Time out error"); + break; + case IDDHTLIB_ERROR_RESPONSE_TIMEOUT: + Serial.println("Error\n\r\tResponse time out error"); + break; + case IDDHTLIB_ERROR_DATA_TIMEOUT: + Serial.println("Error\n\r\tData time out error"); break; case IDDHTLIB_ERROR_ACQUIRING: Serial.println("Error\n\r\tAcquiring"); From d5ec9e018558116a2be81d5362e00e581eed9b7d Mon Sep 17 00:00:00 2001 From: Alex Gutowski Date: Mon, 28 Oct 2013 00:59:37 -0500 Subject: [PATCH 4/5] Adds timeout error messages for each new error code --- .../idDHT11_Lib_example_Simple.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/idDHT11_Lib_example_Simple/idDHT11_Lib_example_Simple.ino b/examples/idDHT11_Lib_example_Simple/idDHT11_Lib_example_Simple.ino index b43182a..28c3ef6 100644 --- a/examples/idDHT11_Lib_example_Simple/idDHT11_Lib_example_Simple.ino +++ b/examples/idDHT11_Lib_example_Simple/idDHT11_Lib_example_Simple.ino @@ -47,8 +47,14 @@ void loop() case IDDHTLIB_ERROR_CHECKSUM: Serial.println("Error\n\r\tChecksum error"); break; - case IDDHTLIB_ERROR_TIMEOUT: - Serial.println("Error\n\r\tTime out error"); + case IDDHTLIB_ERROR_ISR_TIMEOUT: + Serial.println("Error\n\r\tISR time out error"); + break; + case IDDHTLIB_ERROR_RESPONSE_TIMEOUT: + Serial.println("Error\n\r\tResponse time out error"); + break; + case IDDHTLIB_ERROR_DATA_TIMEOUT: + Serial.println("Error\n\r\tData time out error"); break; case IDDHTLIB_ERROR_ACQUIRING: Serial.println("Error\n\r\tAcquiring"); From 6bc02837033f31cfb43808b211c49609a01dea54 Mon Sep 17 00:00:00 2001 From: Alex Gutowski Date: Mon, 28 Oct 2013 01:06:55 -0500 Subject: [PATCH 5/5] Adds more time to acquire data Example code consistently times out while grabbing data. Increasing the delta range for data acquisition fixes this. --- idDHT11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idDHT11.cpp b/idDHT11.cpp index 4f03667..c24bee7 100644 --- a/idDHT11.cpp +++ b/idDHT11.cpp @@ -90,7 +90,7 @@ void idDHT11::isrCallback() { detachInterrupt(intNumber); status = IDDHTLIB_ERROR_DELTA; state = STOPPED; - } else if(6090) //is a one bits[idx] |= (1 << cnt); if (cnt == 0) { // whe have fullfilled the byte, go to next