No dht22 readings on esp8266

hi,I'm using a esp8266 MOD with dht22 but i can't get any readings,this is following code and what i get on the serial moniter.


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <DHT.h>

#define DHTPIN 6    
#define DHTTYPE DHT22  
DHT dht(DHTPIN, DHTTYPE);
void setup() {
  Serial.begin(9600);
  dht.begin();
  Serial.println("Device Started");
  Serial.println("-------------------------------------");
  Serial.println("Running DHT!");
  Serial.println("-------------------------------------");

}
void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  
  if (isnan(h) || isnan(t) ) {
    Serial.println("Failed to read from DHT sensor!");
    return;
    }
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  delay(3000);
}
![image|690x280](upload://hGFYaxHuwUQ3EUVSQ8JQJcpeIT4.png)
any help!!!

Cannot see your image.

Add a delay to loop( ) to slow things down a bit:

delay(2000);

Try:

float hum;  //Stores humidity value
float temp; //Stores temperature value

. . .

void loop()
{
    delay(2000);
    //Read data and store it to variables hum and temp
    hum = dht.readHumidity();
    temp= dht.readTemperature();
    //Print temp and humidity values to serial monitor
    Serial.print("Humidity: ");
    Serial.print(hum);
    Serial.print(" %, Temp: ");
    Serial.print(temp);
    Serial.println(" Celsius");
}

tried it but nothing change

Before going further, please confirm that you can upload a simple sketch like Blink to your controller.


Let’s see your wiring ?


Probably not a good idea to return from loop(). If you remove this statement what happens?

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