Go Down

Topic: DHT22 not working (Read 257 times) previous topic - next topic

shazool

Jul 19, 2019, 01:57 pm Last Edit: Jul 19, 2019, 02:01 pm by shazool
Good morning gentlemen,

I've been testing out some new sensors and this one is giving me a lot of trouble. It seems no matter what I try, the Arduino can't seem to read from it.

At first I was using an ESP8266, but it kept erroring. I thought it was the platform so I tried an ESP-specific library.
Still didn't work, so I switched to my Uno and 5V instead of 3.3.
Still nothing. I tried out 5 more libraries, switched pins, swapped breadboard, swapped wires. To no avail.

The wiring has pretty much been the same for every attempt: 5V and GND connected to the DHT22 and its data pin hooked up to the Arduino with a pull-up resistor (see attachment).



Libraries I've used: DHT sensor library (latest version, dependent on Adafruit's Unified Sensors), DHT sensor library (1.2.3, no dependencies), DHT sensor library for ESPx, SDHT, SimpleDHT, TroykaDHT

Code came straight from the example folder of each, with no modifications except for pin # and DHT type.

Currently I am using:

Code: [Select]
#include <TroykaDHT.h>

DHT dht(4, DHT22);

void setup()
{
  Serial.begin(9600);
  dht.begin();
}

void loop()
{
  dht.read();
  switch(dht.getState()) {
    case DHT_OK:
      Serial.print("Temperature = ");
      Serial.print(dht.getTemperatureC());
      Serial.println(" C \t");
      Serial.print("Temperature = ");
      Serial.print(dht.getTemperatureK());
      Serial.println(" K \t");
      Serial.print("Temperature = ");
      Serial.print(dht.getTemperatureF());
      Serial.println(" F \t");
      Serial.print("Humidity = ");
      Serial.print(dht.getHumidity());
      Serial.println(" %");
      break;
    case DHT_ERROR_CHECKSUM:
      Serial.println("Checksum error");
      break;
    case DHT_ERROR_TIMEOUT:
      Serial.println("Time out error");
      break;
    case DHT_ERROR_NO_REPLY:
      Serial.println("Sensor not connected");
      break;
  }
  
  delay(2000);
}


and I'm getting 'Sensor not connected'


I can't think of anything else to try.. Your help would truly be appreciated

pylon

Have you tried to use another sensor? You may have damaged that one in earlier tests.

shazool

Have you tried to use another sensor? You may have damaged that one in earlier tests.
I only have this one unfortunately

vt71626

i am still have the same problem i used my other one it still saying error: dht.h: No such file or directory

shazool

i am still have the same problem i used my other one it still saying error: dht.h: No such file or directory
That's an issue with your IDE, not the hardware. Did you download the DHT library?

shazool

I got my issue resolved after all - damn ebay jumper cables...

Romonaga

I got my issue resolved after all - damn ebay jumper cables...
Jumper cables fixed a file not found error.  Interesting.

raymw

Jumper cables fixed a file not found error.  Interesting.
two different problems/users

shazool

Jumper cables fixed a file not found error.  Interesting.
Youre mistaken sir

Go Up