DHT22 library, based on Simon Cooksey's. Improved with some error checking and more rigid timing (interrupts off).
Fork of lib_dht22 by
Diff: dht22.cpp
- Revision:
- 2:02cbaab7c6cd
- Parent:
- 0:257ba13e416e
- Child:
- 3:40df3c72813f
--- a/dht22.cpp Wed Jan 06 15:36:07 2016 +0000 +++ b/dht22.cpp Wed Nov 02 16:29:53 2016 +0000 @@ -19,6 +19,7 @@ */ int DHT22::wait_for_edge(edge_type_t type) { + //__disable_irq (); dht22_s.input(); // Timing is done by increasing this number, as the Timer class appears to @@ -31,6 +32,7 @@ // wait for the edge to transition properly wait_us(2); + //__enable_irq (); return time; } @@ -39,11 +41,13 @@ */ void DHT22::send_start() { + //__disable_irq (); dht22_s.output(); dht22_s = 0; wait_us(DHT22_START_BIT_TIME); dht22_s = 1; dht22_s.input(); + //__enable_irq (); } /*