DHT22 time out error? esp8266-12 with Rob Tillaart example sketch

hi, trying hard to get a DHT22 working (using direct 5v PSU & 5.1k resistor between V & signal) with ESP8266-12 (on GPIO14), using the Rob Tillaart sketch (from dht.h - version: 0.1.13 library):

//
//    FILE: dht22_test.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.03
// PURPOSE: DHT library test sketch for DHT22 && Arduino
//     URL:
// HISTORY:
// 0.1.03 extended stats for all errors
// 0.1.02 added counters for error-regression testing.
// 0.1.01
// 0.1.00 initial version
//
// Released to the public domain
//

#include <dht.h>

dht DHT;

#define DHT22_PIN 5

struct
{
    uint32_t total;
    uint32_t ok;
    uint32_t crc_error;
    uint32_t time_out;
    uint32_t connect;
    uint32_t ack_l;
    uint32_t ack_h;
    uint32_t unknown;
} stat = { 0,0,0,0,0,0,0,0};

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

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

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

    stat.total++;
    switch (chk)
    {
    case DHTLIB_OK:
        stat.ok++;
        Serial.print("OK,\t");
        break;
    case DHTLIB_ERROR_CHECKSUM:
        stat.crc_error++;
        Serial.print("Checksum error,\t");
        break;
    case DHTLIB_ERROR_TIMEOUT:
        stat.time_out++;
        Serial.print("Time out error,\t");
        break;
    case DHTLIB_ERROR_CONNECT:
        stat.connect++;
        Serial.print("Connect error,\t");
        break;
    case DHTLIB_ERROR_ACK_L:
        stat.ack_l++;
        Serial.print("Ack Low error,\t");
        break;
    case DHTLIB_ERROR_ACK_H:
        stat.ack_h++;
        Serial.print("Ack High error,\t");
        break;
    default:
        stat.unknown++;
        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.println();

    if (stat.total % 20 == 0)
    {
        Serial.println("\nTOT\tOK\tCRC\tTO\tUNK");
        Serial.print(stat.total);
        Serial.print("\t");
        Serial.print(stat.ok);
        Serial.print("\t");
        Serial.print(stat.crc_error);
        Serial.print("\t");
        Serial.print(stat.time_out);
        Serial.print("\t");
        Serial.print(stat.connect);
        Serial.print("\t");
        Serial.print(stat.ack_l);
        Serial.print("\t");
        Serial.print(stat.ack_h);
        Serial.print("\t");
        Serial.print(stat.unknown);
        Serial.println("\n");
    }
    delay(2000);
}
//
// END OF FILE
//

i'm getting this serial output error:

DHT22, Time out error, -999.0, -999.0, 2306
DHT22, Time out error, -999.0, -999.0, 2309
DHT22, Time out error, -999.0, -999.0, 2305
DHT22, Time out error, -999.0, -999.0, 2309
DHT22, Time out error, -999.0, -999.0, 2306

etcetera...

using this board manager version:

https://github.com/esp8266/Arduino
& http://arduino.esp8266.com/versions/1.6.5-947-g39819f0/doc/reference.html

using Arduino 1.6.4 IDE

can anyone assist?

thanks!

i just checked, - i had the ESP8266 firmware: nodemcu_integer_0.9.6-dev_20150627.bin loaded...

i just uploaded: nodemcu_float_0.9.6-dev_20150627.bin firmware...

still same error?

never tried it on a esp8266 disclaimer applies :wink:

What is the clock speed of the esp?

Can you try it with a smaller resistor, e.g 2K2?

Thanks,

it is 80mhz clock.

I will try a 2k2 tonight...

80 Mhz should be more than fast enough

Read - Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino - especially the part about pull up resistors.

I cannot explain it better.

Thanks for the link & help, I've learned much while working this out!

But I ditched the bread board and soldered everything and it works fine (with no resistor, 2k2 and 5k1).

Pretty sure the bread board was the issue.

Next up is getting 3 sensors working on 5m long wiring, then using dew point to control 3 relays :slight_smile: