From 56a9c93647fd4ba582349e044acc6f2266558b6f Mon Sep 17 00:00:00 2001 From: william_lai Date: Wed, 27 Jan 2016 17:14:22 +0800 Subject: [PATCH] Title: Fix DHT22 fail to read issue 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. --- hardware/libraries/GPIO/DHT.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hardware/libraries/GPIO/DHT.cpp b/hardware/libraries/GPIO/DHT.cpp index 9d2a94c..fa2547d 100644 --- a/hardware/libraries/GPIO/DHT.cpp +++ b/hardware/libraries/GPIO/DHT.cpp @@ -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