Description
Dear all,
there is an mistake in your DHT11 init sequence. Admittedly, the DHT11 datasheet is not very clear here. Anyhow, 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.
This can clearly be seen on an oscilloscope if your lib is used "as is".
You need to change the uC pin state to "INPUT" after the initial >18 msec LOW phase right away, without actively pulling up before.
Luckily this bugfix is as easy as commenting out two lines, see below:
'''
// End the start signal by setting data line high for 40 microseconds.
// digitalWrite(_pin, HIGH);
// delayMicroseconds(40);
// WEB: This is an error. DHT tries to pull the line low as soon as it came back to high.
// therefore the low-high transition after the start signal "low" needs to be realised by
// the pullup resistor only, uC pin must already be in INPUT mode.
'''
See attached before-after scope screenshots
after, with fixed startup sequence:
With best regards,
Wolfgang Ebersbach