Skip to main content

Arduino Uno Sensor DHT11 Failed to read from DHT sensor

Hey guys i get this error everytime. I used the DHT tester file from the library : https://codeload.github.com/adafruit/DHT-sensor-library/zip/master wich gave me this error.

And then in my code i realize that Arduino recognize only the readTemperature function, not the readHumidity, but it doesnt give any compile error. Also when i read the sensor, this is the output:

Humidity Sensor Test
Temp: 0C, Humidity: 0%
Temp: 0C, Humidity: 0%
Temp: 0C, Humidity: 0%

My code is here:

//DHT11 Sensor:
#include "DHT.h"
#define DHTPIN 5    // what digital pin we're connected to
#define DHTTYPE DHT11   // DHT 11

DHT dht(DHTPIN, DHTTYPE);


//I2C LCD:
#include <Wire.h> // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>

// Set the LCD I2C address
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 


void setup() {
  Serial.begin(9600);
  delay(300);
  lcd.begin(16,2);
  Serial.println("Humidity Sensor Test");

  dht.begin();
  delay(300);
}

void loop() {
    // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  int h = dht.readHumidity();
  int t = dht.readTemperature();

    // set the cursor to (0,0):
  lcd.setCursor(0, 0);
  // print from 0 to 9:

   lcd.print("Temp: ");
   lcd.print(t);
   lcd.print("C");
  
  // set the cursor to (16,1):
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(h);
  lcd.print("%");
    
  Serial.print("Temp: ");
  Serial.print(t);
  Serial.print("C, Humidity: ");
  Serial.print(h);
  Serial.println("%");

  delay(2500);
}

Also i have the 10k resistor between Data and power and connected to digital pin 5. Anyone had this problem before?