Arduino Forum

Using Arduino => Sensors => Topic started by: shazool on Jul 19, 2019, 01:57 pm

Title: DHT22 not working
Post by: shazool on Jul 19, 2019, 01:57 pm
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).

(https://i.postimg.cc/CSHS8QQL/IMG-20190719-073101.jpg)

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
Title: Re: DHT22 not working
Post by: pylon on Jul 19, 2019, 07:29 pm
Have you tried to use another sensor? You may have damaged that one in earlier tests.
Title: Re: DHT22 not working
Post by: shazool on Jul 20, 2019, 12:25 am
Have you tried to use another sensor? You may have damaged that one in earlier tests.
I only have this one unfortunately
Title: Re: DHT22 not working
Post by: vt71626 on Jul 20, 2019, 07:21 pm
i am still have the same problem i used my other one it still saying error: dht.h: No such file or directory
Title: Re: DHT22 not working
Post by: shazool on Jul 21, 2019, 03:54 am
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?
Title: Re: DHT22 not working
Post by: shazool on Jul 21, 2019, 04:08 am
I got my issue resolved after all - damn ebay jumper cables...
Title: Re: DHT22 not working
Post by: Romonaga on Jul 21, 2019, 07:12 pm
I got my issue resolved after all - damn ebay jumper cables...
Jumper cables fixed a file not found error.  Interesting.
Title: Re: DHT22 not working
Post by: raymw on Jul 21, 2019, 10:24 pm
Jumper cables fixed a file not found error.  Interesting.
two different problems/users
Title: Re: DHT22 not working
Post by: shazool on Jul 22, 2019, 05:34 am
Jumper cables fixed a file not found error.  Interesting.
Youre mistaken sir