DHT plugin code change needed?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
linker3000
Normal user
Posts: 12
Joined: 08 May 2017, 09:51

DHT plugin code change needed?

#1 Post by linker3000 » 08 May 2017, 22:55

Edit: 10-May-2017: Fixed via github: https://github.com/letscontrolit/ESPEasy/pull/285

I was playing with a DHT11 sensor module and ESP Easy 147RC8 on a Wemos D1 mini, with Mosquitto & Node-Red. I was getting about 5% NaN readings for temperature and humidity so I did a bit of research and came across this thread about the Adafruit code that seems to be the basis for the ESPEasy DHT plugin:

"DHT init sequence wrong" : https://github.com/adafruit/DHT-sensor- ... /issues/48

"...after you pulled the data line low for the at least 18 milliseconds to signal the DHT11 a start, you should NOT actively pull it up. As soon as the DHT does see the low-high transition on the data line ( Well "as soon is around 12 usec later) it tries to pull it down. If the data line is still held "high" by the uC at that time, you have more or less a short circuit on the data line with the uC pulling up and the DHT pulling down."

In code, this means commenting out one line in the plugin (_P005_DHT.ino) around line 98:

Code: Select all

 pinMode(Plugin_005_DHT_Pin, OUTPUT);
// DHT start condition, pull-down i/o pin for 18ms
digitalWrite(Plugin_005_DHT_Pin, LOW);              // Pull low
delay(18);
//digitalWrite(Plugin_005_DHT_Pin, HIGH);             // Pull high <<< COMMENT OUT THIS LINE
delayMicroseconds(20); // was 40
I recompiled and ran the code with this change and now get zero NaN values.

I'd appreciate thoughts and additional testing!

Cheers

L3K
Last edited by linker3000 on 10 May 2017, 21:08, edited 1 time in total.

livebelive
Normal user
Posts: 13
Joined: 08 May 2017, 22:50

Re: DHT plugin code change needed?

#2 Post by livebelive » 08 May 2017, 22:59

How to create a new post
I need help!!!

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests