So I'm new and I don't know why its giving out the wrong information. I'm using the DHT11 Humidity + Temp Sensor on a breadboard. I followed a video so I'm fairly certain I hooked it up correctly electronics wise but maybe its the code that is the problem? Right now when I compile and upload it to my board, I pop up the serial monitor and it dose everything I told it to do besides the fact it thinks my room has -999% humidity and -999% temp. Any ideas as to why this isn't working?
Code:
#include "dht.h"
#define dht_apin A0 // Analog Pin sensor is connected to
dht DHT;
void setup(){
Serial.begin(9600);
delay(500);//Delay to let system boot
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);//Wait before accessing Sensor
}//end "setup()"
void loop(){
//Start of Program
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");
delay(5000);//Wait 5 seconds before accessing sensor again.
//Fastest should be once every two seconds.
}// end loop()
there seem to be a lot of dht-libraries on the internet.
The one you are using has different functions as the one that comes with the arduino-IDE
A0 can be used as a digital pin but is unusual. usually a digital pin us used
So without providing the exact dht-library you are using it is not possible to say where the bug might be
I suggest to install the DHTNew-library from the Arduino-IDE library manager
and then test with one of the example-codes if it works
the command
DHTNEW mySensor(6);
says that the datapin of the DHT-sensor is connected to IO-pin 6
which is a good choice
best regards Stefan
Please post a schematic of your circuit. A photo of a pencil and paper drawing is goo enough
I assume that you have checked your wiring and that the sensor is correctly attached to VCC, GND and pin A0 and that all the connections are secure. If this is on a breadboard and you are using the power rails top and bottom make sure that they have not got a break in the centre of them, which many do.
Which Arduino board are you using ?
UKHeliBob:
The OP's not very helpful image
I got it to work anyways! The only thing I did was use the reset switch on the board and tried it again and now its outputting the correct info.
Hi chad,
trying to do things very fast - in reality - slow things down.
Now you have done a quick picture - not reading hwo you can insert pictures into a posting
and your picture doesn't show how the DHT11 is connected and it is very hard to conclude which pins are conected.
bevause it is unsharp and with a lot of parallax-error. (angle instead of taking the picture from vertical above)
Now it needs an extra attempt to make a picture that
- is attached to a posting
- is taken from vertical above
- includes the DHT11 in a way that the wiring can be seen easily
I mentioned using another DHT-library. Try it. If you have questions about hwo to do this ask the questions
But maybe you enjoy beeing in a hassle to slow down finishing your project.
That's okay for me. I enjoy both writing such comments and effective helping people that ask concrete and soecific questions.
best regards Stefan
OK so another user that is convinced quick & dirty works good :-0
I recommend using the DHT library created by Adafruit. See how to install library in Arduino DHT sensor tutorial
aarg:
For an Elegoo? 
For the
DHT11 Humidity + Temp Sensor on a breadboard.
and its connections to the Arduino
Hi,
Have you got a pullup resistor on the DHT data line.
To quote form the link in post#8
Wiring to Arduino is the same for both sensors. In original form, A resistor from 5K to 10K Ohms is required to keep the data line high and in order to enable the communication between the sensor and the Arduino
A proper circuit diagram would help, or a better wider angled picture of your project.
Thanks.. Tom.. 