My DHT11 isn't working

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);
} 

Find the DHT11 datasheet. You probably have it connected incorrectly.

Read this page and watch the video from DroneBotWorkshop:

It does seem to be connected correctly, here's how I connected it:

Show a picture of your wiring (to compare with the drawing and the sketch).

Here it is

So you wired the DHT11 wrong. Note that there are a couple of variants of these DHT11 modules. Yours may be wired differently than you think. E.g.:
image

In your image Vcc and GND texts are inverted, see + and - symbols
Often it is wired like this:
image

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.

It's because when I connect it to the 5V the arduino turns off, so yeah I guess it's broken. I'll try to do it with an LM35 sensor instead, thanks!

But that only reads temperature, not humidity

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