Skip to content

Commit

Permalink
Title: Fix DHT22 fail to read issue
Browse files Browse the repository at this point in the history
Commit:
1.  DHT11 require host start high signal need more than 18us,
    DHT21/22 require host start high signal need between 20~40us.
    Take 20us as safe value instead of 40us.
  • Loading branch information
Ameba8195 committed Jan 27, 2016
1 parent dc7c223 commit 56a9c93
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hardware/libraries/GPIO/DHT.cpp
Expand Up @@ -158,12 +158,12 @@ boolean DHT::read(bool force) {
// and we don't want any interruptions.
InterruptLock lock;

// End the start signal by setting data line high for 40 microseconds.
// End the start signal by setting data line high for 20 microseconds.
digitalWrite(_pin, HIGH);
delayMicroseconds(40);
delayMicroseconds(20);

// Now start reading the data line to get the value from the DHT sensor.
pinMode(_pin, INPUT_PULLUP);
pinMode(_pin, INPUT_PULLNONE);
delayMicroseconds(10); // Delay a bit to let sensor pull data line low.

// First expect a low signal for ~80 microseconds followed by a high signal
Expand Down

0 comments on commit 56a9c93

Please sign in to comment.