From b429942ce8d711e30eb3254fe102434a23d6ea4e Mon Sep 17 00:00:00 2001 From: "W12\\owen" Date: Mon, 24 Sep 2018 06:20:01 +1000 Subject: [PATCH] Fix timing and pin mode change to comply with datasheet. --- DHT.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DHT.cpp b/DHT.cpp index 86ad91c..6ada7e4 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -153,11 +153,10 @@ boolean DHT::read(bool force) { // End the start signal by setting data line high for 40 microseconds. digitalWrite(_pin, HIGH); - delayMicroseconds(40); + pinMode(_pin, INPUT_PULLUP); // Now start reading the data line to get the value from the DHT sensor. - pinMode(_pin, INPUT_PULLUP); - delayMicroseconds(10); // Delay a bit to let sensor pull data line low. + delayMicroseconds(60); // Delay a bit to let sensor pull data line low. // First expect a low signal for ~80 microseconds followed by a high signal // for ~80 microseconds again.