I really think that the DHT11 and DHT22 bus is a open collector bus, and the Arduino should never make the pin output and high.
Most libraries however set the datapin as output and high in the beginning of the data sequence. I think that is wrong.
The datasheets can be read both ways, but the pictures show a slow rising of the signal when it must turn high. That indicates that the pullup resistor makes the signal high, and not the microcontroller. Other datasheet says "releases the bus" for that or "pullup" or "RL pullup".
If the datasheet can be read both ways, then I assume that the bus is a open-collector bus. Therefor the Arduino should not set the signal output and high.
I'm hoping to find someone who can see through a bad translated chinees datasheet and agrees with me.
ADDED: I got the feeling that I was the only one who saw it this way, and I wrote: "This is a: "I'm right and everyone else is wrong"". But it turned out to be a known for years, and others who spend time to look into it already know this.
That indicates that the pullup resistor makes the signal high, and not the microcontroller.
Yes it is principle of open drain.
It is clear: when the micro controller wants to talk to DHTxx he must put the line to 0V.
I think you do not see that the logic is reversed:
Non active state = boolean false = logical “0”, but the voltage = + 5V
Work = boolean true = logical “1”, but the voltage = 0V
There is no obligation to choose the level 0 volts for logic 0 and nothing prohibits to choose the level 5 Volts as logic 0. The only thing that is required is to announce the choice has been done.
It’s like this that all IC using open drain works,
It is because of this principle that you can do simple wired OR function that are so important in I2C busies.
I disagree the term “pull up” : for me a pull up is used to fix a potential, for example on input of a logic gate.
Without this pull up resistor the gate can works. It can be unstable without input signal, but in normal use with an input signal it works perfectly.
With open collector this is absolutelynot the case, it is a misnomer because without this resistor the circuit can not works.
This resistor is not optional, it is mandatory : it is a load resistor.
For Aosong datasheet I totaly agree, there are raw Chinese/English Google translation without any correction.
The worse I found is for AM2320 : shitty POWER(shitty)
An attachment the bestthe least worse that I found for DHT22(AM2302)
Of course, the data pin is active low.
You also agree, that the MCU should never set the data pin output and high ? That makes three of us.
Thanks for that link.
That means that the most used DHT libraries are wrong:
It seems that it is already known for years.
There are even pictures of the data signal during the "more or less a short circuit" !
+1
It would not make sense to have a device pull the line high with an active gate when there are multiple objects on the Data line. Since the boot-up sequence is not common nor synchronized among multiple devices, the Data line state must be assumed unknown and possibly dangerous.
I have difficulty in understanding, not technical, but to well understand English.
You seem to fear that we can have :
case 1:
Simultaneously :
Output of the atmega to High
DHT that draws the line to 0
Which would effectively do a short-cut.
case 2 :
You also seem to fear that when there are multiple modules on the line there could have some which draw to 0 and the other to Vcc, doing short-cut.
If I well understand I replied :
Case 1:
You agree that this is not a normal case.
This would means that the I/o is in output mode and to a high level and DHT draws the line to 0.
If the timing is respected it is impossible except if someone take control of the pin out of the library, for example with an interrupt : it would be foolish,
Be default during wake up phase all I/O of microcontrolers are in INPUT mode.
Case 2:
It is impossible: The DHT protocol supports only one module on a line. That can not work with multiple module
It is Aosong one-wire bus, it is not Dallas one-wire bus .
In I2C mode there may be several modules but A4 and A5 are in this case true open-drain, and there are no risks.
After sending "start" signal, change MCU to input mode. The bus will be pulled up to high by the resistor. Output mode with high level is OK too.
So it makes clear that you can output high, instead of setting it to input mode and let the pull-up resistor do the work. I think that's why some popular libraries have that implementation. It does sound like a second choice though.
I checked the newest datasheets for DHT11 and ASOM2312 (DHT22) (what 68tjs posted above should be translated from this) now they only say
Set MCU's I/O to output and output low level, for at least 18ms. Then set the I/O of MCU to input mode. Because of pull-up resistor, the I/O of MCU (a.k.a. DATA bus) will be high. Wait for DHT11 to response.
So my guess is, both should work normally but apparently input mode work better. So they updated their datasheet. Hardware revision may be also involved, but it's kinda unlikely.
I wish it helps. If you have any other questions about the datasheet feel free to ask me.
Thank you ! Mystery solved.
Perhaps it was possible in the past to set the bus high, perhaps it was a mistake in the datasheet. Perhaps the DHT11 did have electronics inside that allowed it. But the DHT22 today has a microcontroller, which does not allow to make the bus high.