I'm new to Arduino and I'm trying to make a weather station where a DHT11 collects the temperature and humidity data and then it gets displayed on an LCD screen, but it displays nan for both. Something that I noticed is that when I try to connect the DHT into the 5V pin the arduino turns off, and if I have it plugged into my pc it says that the USB disconnected because I surpassed the electricity limit or something along those lines. Here's the code I used and an image of the ciruit.
#include <DHT.h>
#include <DHT_U.h>
#define DHT11Pin 6
#define DHTType DHT11
DHT HT(DHT11Pin,DHTType);
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
HT.begin();
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Temp.");
lcd.setCursor(9,0);
lcd.print("Hum.");
}
void loop() {
// put your main code here, to run repeatedly:
float Hum = HT.readHumidity();
float Temp = HT.readTemperature();
lcd.setCursor(0, 1);
lcd.print(Temp);
lcd.print("'C");
lcd.setCursor(9, 1);
lcd.print(Hum);
lcd.print("%");
delay(1000);
}
Can you follow the traces from sensor to pins?
And if you have multimeter, you could also measure resistance between + and - pins, maybe it's shorted...
Am I wrong but it looks like you are powering the DHT11 with only 3.3V, is that correct?
If yes then that may be the problem, you should be using 5V.
Otherwise, the sensor may be bad.