DHT
Fork of DHT by
Revision 1:42593954052a, committed 2015-02-25
- Comitter:
- mbotkinl
- Date:
- Wed Feb 25 20:23:00 2015 +0000
- Parent:
- 0:9b5b3200688f
- Commit message:
- Commented out some errors in DHT library
Changed in this revision
DHT.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DHT.cpp Mon Jul 09 19:47:43 2012 +0000 +++ b/DHT.cpp Wed Feb 25 20:23:00 2015 +0000 @@ -31,8 +31,9 @@ */ #include "DHT.h" +#define DHT_DATA_BIT_COUNT 41 +DigitalOut myled1(LED2); -#define DHT_DATA_BIT_COUNT 41 DHT::DHT(PinName pin,int DHTtype) { _pin = pin; @@ -47,6 +48,8 @@ int i, j, retryCount,b; unsigned int bitTimes[DHT_DATA_BIT_COUNT]; + + //myled1=0; eError err = ERROR_NONE; time_t currentTime = time(NULL); @@ -56,15 +59,15 @@ bitTimes[i] = 0; } - if (!_firsttime) { - if (int(currentTime - _lastReadTime) < 2) { - err = ERROR_NO_PATIENCE; - return err; - } - } else { - _firsttime=false; - _lastReadTime=currentTime; - } +// if (!_firsttime) { +// if (int(currentTime - _lastReadTime) < 2) { +// err = ERROR_NO_PATIENCE; +// return err; +// } +// } else { +// _firsttime=false; +// _lastReadTime=currentTime; +// } retryCount = 0; do { @@ -79,6 +82,21 @@ DHT_io.output(); DHT_io = 0; + + + +// wait(.1); +// DHT_io=1; +// wait(.1); +// DHT_io=0; +// return 0; + + + + + + + wait_ms(18); DHT_io = 1; wait_us(40); @@ -134,14 +152,14 @@ DHT_data[i]=b; } - if (DHT_data[4] == ((DHT_data[0] + DHT_data[1] + DHT_data[2] + DHT_data[3]) & 0xFF)) { + if (DHT_data[4] == ((DHT_data[0] + DHT_data[1] + DHT_data[2] + DHT_data[3]) & 0xFF)) { _lastReadTime = currentTime; _lastTemperature=CalcTemperature(); _lastHumidity=CalcHumidity(); } else { err = ERROR_CHECKSUM; - } + } return err;