Interval between reads of DHT sensor

I am investigating the timing of the DHT (11,21,22) sensor.
One aspect is the delay between reads. Documentation mentions 2000 milliseconds between reads but my tests indicate that 360-370 millis is approx the limit (UNO, DHT22 10 cm wires). In practice 500 (1000) might work quite well.

If you have a DHT sensor and some time to spare, please run this test and post a part of the output where it alternates

The sketch below searches this value automatically

//
//    FILE: dht22_test.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.01
// PURPOSE: DHT library test sketch for DHT22 && Arduino
//     URL:
//
// Released to the public domain
//

#include <dht.h>

dht DHT;

#define DHT22_PIN 5

void setup()
{
    Serial.begin(115200);
    Serial.println("DHT TEST PROGRAM ");
    Serial.print("LIBRARY VERSION: ");
    Serial.println(DHT_LIB_VERSION);
    Serial.println();
    Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)");
}

int del = 500;

void loop()
{
    // READ DATA
    Serial.print("DHT22, \t");

    uint32_t start = micros();
    int chk = DHT.read22(DHT22_PIN);
    uint32_t stop = micros();

    switch (chk)
    {
    case DHTLIB_OK:
        Serial.print("OK,\t");
        del -= 10;
        break;
    case DHTLIB_ERROR_CHECKSUM:
        Serial.print("Checksum error,\t");
        break;
    case DHTLIB_ERROR_TIMEOUT:
        Serial.print("Time out error,\t");
        del += 10;
        break;
    default:
        Serial.print("Unknown error,\t");
        break;
    }
    // DISPLAY DATA
    Serial.print(DHT.humidity, 1);
    Serial.print(",\t");
    Serial.print(DHT.temperature, 1);
    Serial.print(",\t");
    Serial.print(stop - start);
    Serial.print(",\t");
    Serial.print(del);
    Serial.println();

    delay(del);
}
//
// END OF FILE
//

some output lines

DHT22, 	OK,	44.0,	20.0,	4792,	360
DHT22, 	Time out error,	-999.0,	-999.0,	51392,	370
DHT22, 	OK,	44.0,	20.0,	4800,	360
DHT22, 	Time out error,	-999.0,	-999.0,	51388,	370

What about the accuracy of the values ?
The temperature will be okay, but I measured a year ago different humidity values with shorter delays.
I can't run your test now, Sorry.

What about the accuracy of the values ?
The temperature will be okay, but I measured a year ago different humidity values with shorter delays.

Indeed a good question, I can check .

no effect here,
2 second delay gives same (0.1 difference) value as 400 millis for humidity and Temperature.

Rob, I am on the road back from the Miami MakerFaire. I just had to also stop in the Florida Keys to check that the fish are OK. The first few thousand I checked are OK.

I have only DHT11 with me, but I'll try to check a few of them.

Thanks for your detailed work on this and many other things Arduino-related.

so, it works with a 360 ms delay, and it doesn't work with a 370 ms delay ?

That seems obscure, to me.

Well noticed! :blush:

It is a known bug in my code - it in/decreases the time before it is printed - should be updated after printing.
For finding the approx edge value it worked for me, still a bug

Anyhow I would not use 370 anyway, would use e.g. 500 to not be on the edge.
(the minimal time might even be temperature or humidity dependant)