8 years, 1 month ago.

wait(1);

Hi,

In the readData function, there is a comment says wait 500uS forDHT22 and wait(1) is used

    // only 500uS for DHT22 but 18ms for DHT11
    (_DHTtype == 11) ? wait_ms(18) : wait(1);

I am confused of what wait(1) means, wait 1 second or wait mS!

Here (https://developer.mbed.org/handbook/Wait) it says wait() is in seconds. But the code in DHT.cpp meant 1mS

Please advise

Question relating to:

/ DHT
Temp and Humidity sensor device driver. DHT11, DHT22

1 Answer

8 years, 1 month ago.

You are reading the code correctly, it's waiting 18ms for a DHT11 and 1 second for everything else.

Assuming the comment is correct it should be safe to change that to wait_ms(1) or even wait_us(500)

Accepted Answer