DHT library modify for DHT11 - DHT22 - AM2302
Fork of DHT by
Diff: DHT.cpp
- Revision:
- 3:24682a533803
- Parent:
- 2:df22ddf10d75
- Child:
- 4:0242d8d27c1e
--- a/DHT.cpp Fri Aug 15 20:55:43 2014 +0000 +++ b/DHT.cpp Wed Mar 02 18:59:28 2016 +0000 @@ -51,6 +51,7 @@ int cnt = 0; while (level == io) { if (cnt > max_time) { + return ERROR_NO_PATIENCE; } cnt++; @@ -78,10 +79,11 @@ DHT_io.output(); DHT_io = 0; // only 500uS for DHT22 but 18ms for DHT11 - (_DHTtype == 11) ? wait_ms(18) : wait(1); + (_DHTtype == 11) ? wait_ms(18) : wait_us(500); DHT_io = 1; wait_us(30); DHT_io.input(); + // wait till the sensor grabs the bus if (ERROR_NONE != stall(DHT_io, 1, 40)) { return ERROR_NOT_PRESENT;