The old shortcutting the signal mistake ![]()
// shortcut
digitalWrite(this->_comm_pin, HIGH); // shortcut !
delayMicroseconds(START_WAIT_US);
The first datasheets of the DHT11 (in Chinese) are not very clear about the open-collector or open-source behaviour of the signal wire. That is why some libraries make the signal OUTPUT and HIGH. That causes a shortcut in the signal.
Finally someone actually showed the shortcut with a scope: https://github.com/adafruit/DHT-sensor-library/issues/48
Ignore any confusing information in the datasheet. The pictures in the datasheet are sometimes wrong. The signal wire is a open-collector or open-source signal. Do not set the Arduino to OUTPUT and HIGH.
Set the signal as INPUT and led the pullup resistor make the signal high.
A second problem is the sequence of code when setting the pin as OUTPUT LOW. As far as I know, every Atmel microcontroller allows that the output value can be written before a pin is set as output.
To be sure that the pin never gets OUTPUT and HIGH when setting a pin OUTPUT LOW, you can alter the sequence:
// Not good
// When the pin is set as OUTPUT, it might become high, depending on a previous state.
pinMode(this->_comm_pin, OUTPUT); // could create a shortcut
digitalWrite(this->_comm_pin, LOW);
// Good
// The pin becomes never OUTPUT HIGH.
digitalWrite(this->_comm_pin, LOW);
pinMode(this->_comm_pin, OUTPUT);