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:
#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