Time out error? Arduino Nano (Temp Sensor)

Hi! Anyone could help with this?
I am getting what I think is a time out message on my nano in the serial data in Arduino IDE.

Any pointers would be cool!
I have 10k resistor on the data pin,

#include <Wire.h>
#include <DHTStable.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

DHTStable dht;
hd44780_I2Cexp lcd;

#define DHT11_PIN 2

const int LCD_COLS = 16;
const int LCD_Rows = 2;

int buttonState1 = 0;
const int But2 = 11; 

int buttonState = 0; 
const int But1 = 12; 

 
byte termometru[8] = {
  B00100, B01010, B01010, B01110, B01110, B11111, B11111, B01110}; //chart for temperatura

byte picatura[8] = {
  B00100, B00100, B01010, B01010, B10001, B10001, B10001, B01110,}; //char for humidity


void setup()
{
  DHTStable();
  lcd.begin(20, 4);
   Serial.begin(9600);
   Serial.println(__FILE__);
   Serial.print("LIBRARY VERSION: ");
   Serial.println(DHTSTABLE_LIB_VERSION);
   Serial.println();
   Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)\tTime (us)");
}


void display()
{

  lcd.write(1);
  lcd.setCursor(0, 1);
  lcd.print(dht.getTemperature()); 
  lcd.print(" ");
  lcd.print((char)223); 
  lcd.print("C"); 

  lcd.setCursor(10, 1);
  lcd.write(2); 
  lcd.print(dht.getHumidity()); 
  lcd.print(" "); 
  lcd.print("%"); 
} 

void buton()
{
  buttonState = digitalRead(But1);
  delay(10); 
  if (buttonState == HIGH) 
  { 
    lcd.backlight(); 
  }
  else {
    lcd.noBacklight(); 
  }
}


void loop() 
{

  int chk = dht.read11(DHT11_PIN);
  delay(2000);
   
  buton();

  Serial.print("T: ");
  Serial.println(dht.getTemperature());
  Serial.print("H: ");
  Serial.println(dht.getHumidity());
  

}

and the error message;

Type, status, Humidity (%), Temperature (C)
DHT11, Time out error, -999.0, -999.0

Seems the library tells you it did not get data from the DHT11

In the library example they handle this by doing

int chk = DHT.read11(DHT11_PIN);
  switch (chk)
  {
    case DHTLIB_OK:  
      Serial.print("OK,\t"); 
      break;
    case DHTLIB_ERROR_CHECKSUM: 
      Serial.print("Checksum error,\t"); 
      break;
    case DHTLIB_ERROR_TIMEOUT: 
      Serial.print("Time out error,\t"); 
      break;
    default: 
      Serial.print("Unknown error,\t"); 
      break;
  }

Hi thanks, its strange because I use the library and it doesn't work either. hm.

can you share a link to your DHT11 module?
did you wire your DHT correctly? good cables? how long?
has this DHT11 ever worked?

yep - its from Botland.pl(I live in PL) Czujnik temperatury i wilgotności DHT11 - moduł + przewody Sklep Botland into Arduino Nano, and im unsure if its ever worked, I have 2 sensors, both new (1 straight out of packaging just now) cables are 5/6 or so hookup wires. - Arduino Nano took a while to get going but all working now.




I attached photos, apologies my camera isn't so good. On the sensor its + out. Red is +, grey is out(data) and orange is -

Hey - no worries I fixed it. My pinouts were a mess :stuck_out_tongue: thanks!

:crazy_face:LOL - we have all been there

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.