DHT11 Temperature & Humidity sensor with Arduino - Tutorial
HTML-код
- Опубликовано: 3 окт 2024
- Let's read some temperature and humidity with the help of this DHT11 module and an Arduino UNO.
To download the library we used and the sketch please check out our tutorials page at : brainy-bits.co...
For everyone only reading 0% and 0 degrees:
Some DHT11 sensors have the signal pin on the left. Meaning you should connect it like this:
Connect the negative pin (right) to GND.
Connect the positive pin (middle) to 5V.
Connect the signal pin (left) to pin 7.
In the code change DHT.read11(dht_apin); to DHT.read11(7);
Hope this helps 😁
Everyone keep in mind that he used a sensor mounted on a pcb. If you have just the bare sensor, you need a resistor across the analog and 5v pins or it won't work correctly. His already had this resistor on the pcb.
i would like to know one thing. Is it mandatory to connect the data pin to A0 ?Can I connect it to any digital pin instead?
@@madmaddy9473 u need to connect the pin to any analog pin, it cannot be in digital, because the value is in analog format
Tried many videos ......Yours Worked (THANKS)
For anyone with the ERROR: 'DHT.h' there is no such file:
Change DHT to dht (small letters) in the beginning of the file.
Thanks dude you're a lifesaver
i am still facing the erroe.(error compiling for arduino genuino uno)
even though i change to small letter still got the same error on that
@@m.iinnovations8229 any fix for that
@@yusufabubakar9862 ^
Hey Brainy , super easy and fast! thank you , if you allow me to say something , there is a huge difference of volume of sound between the start of video and in the middle. thanks again!
+Cadu da toro Hi, this was one of our earlier videos, so I was still new to making videos for RUclips and didn't have the best equipment :) Our newer videos are a little better I hope, but always learning to make them better... Thanks for watching btw!
It helps me for my robotic project thank you.
the stability of the readings from your sensor seem to be very erratic!
Hi need help I am getting zero for both temp as well as humidity. Tried all possible connections with this code. I have 3 pin dht11. What could be the possible reason????
Need help
mee
too
I'm a bit confused, the DHT11 is supposed to deliver a digital reading, not analog?
I am impressed - Your videos are incredibly impressive and genuinely helpful😀
thank you. it worked for me nice and well. thankyou for the library also
0q2bsyng💝💗💓💝💗💕💙👍💞💗
For whatever reason, the temp and humidity both keep showing only zero
I need to look at the datasheet for this. It shows humidity going from 63% up to 75% after only a few seconds. Seems like a large drift in a short period of time.
I'm pretty sure that it is due to the humidity sensor being a capacitative sensor. Right when you turn it on the sensor is powered through vcc and charge begins building up on the capacitor. This is what appears as your initial drift.
Maybe it's because you are breathing on the sensor
I am not getting any errors but the Serial Monitor only gives me 0,00% Humidity and 0 C. The Library must be broken somehow
I managed to get it working. I used a diffrent library and changed arround the vcc and the signal Pin. Most charts online are actually wrong!!
@@theIfrit552 can you give me your lib bro?
Ya we need ur library 🥺
Nevermind, everything has worked properly. However, why does it always give me values of 0 for temperature and humidity ?
ho! my good, finally its woek, i tested many codes, thanks you!....
川崎春と Thanks for the comment! Always great to hear that it's working! :)
Works like a charm
'dht' does not name a type how do i fix this?
after adding library, it also says error
Mine says: "Current humidity = 0.00% temperature = 0.00C"
Really helped, thank you!
it's nice and clean, thanks!
Thanks man.
That works.
Any tutorial to use the sensor and a ESP8266 to check the data through an internet connection?
lovely tutorial thanks for this
the code is correct. Connect the data pin to A0 on the Arduino Uno Board.
mine keeps reading 0
Dont use an analog pin, use a digital one. That should do the trick
it worked, but it always say "Current humidity = 0.00% temperature = 0.00C
"
how did you fix this?
my output for temperature and humidity both are -999 always.. can u help??
the signal pin was not the middle
Ivan, you are so wrong. The DHT11 should NOT be connected to an ANALOG input. It's got to be one of the PWM pins.
Awesome thank you brother
Thanks for taking the time to comment and for watching Tony. Cheers!
I had to troubleshoot my sensor for an hour before I found your library download link for DHT.h + the accompanying code., I have the stater kit from elegoo, it doesn't have the best file set. I tried adding the files from elegoo to the library manually and also thru the add .zip function, however this just did not work. Errors after everything I tried. Anyways what im saying is I appreciate what you do! Thanks alot!
After half a dozen kits, could never get this piece of vaporware working. I think the DHT11 is just a piece of plastic to look like a module that will never work!
My sensor has the center pin as positive once I switched the data and positive it worked well.
Thanks for sharing your experience and for watching of course!
The same worked for me my sensor came from the Elegoo super starter kit.
Thank you Sir, IT worked for me too! Just interchanged the Analog and positive. LOVE YOU! I got kit from RobuIn
I check my Arduino library and there is no such file as DHT or dht. what should I do?
I have that same problem and I've been searching for hours. did you ever figure out what to do
Hi!! Thank you for the video... I had this error when compiling, compiler says: "'dht' does not name a type"
Download github.com/RobTillaart/Arduino/archive/master.zip
Copy the Arduino-master/libraries/DHTstable subfolder of the downloaded file to the libraries subfolder of your sketchbook folder. You can find the location of your sketchbook folder at File > Preferences > Sketchbook location in the Arduino IDE.
Great video and instructions. One question, shouldn't there be a pull up resistor for this setup ?
The Pull up resistor is for the non PCB version of this sensor, I heard this from other tutorial, Saludos
*NOTE: If you use a DTH11 or DHT22 module, these might already have a PullUp resistor installed onboard, in that case you shouldn’t use the internal PullUp resistor of the Arduino.
www.brainy-bits.com/dht11-and-dht22-with-arduino/
Not workinf for me dht.H nO SUCH FULE OR DIRECTORY WTH I DOWNLOADED THE LIBRARY
Can you please include library properties? I want to code it in arduino droid for Android. It asks for library.properties
Why can't my sensor be placed in a position facing the Arduino (just as the one in your video). My sensor can only be placed from the other side, where the Arduino is on its right side, not facing it.
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Uno"
temp:1:10: fatal error: dht.h: No such file or directory
#include "dht.h"
^~~~~~~
compilation terminated.
exit status 1
dht.h: No such file or directory
Invalid library found in C:\Users\shiva\OneDrive\Documents\Arduino\libraries\DHT_Library: no headers files (.h) found in C:\Users\shiva\OneDrive\Documents\Arduino\libraries\DHT_Library
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
@DHT.readll(dht_apin);
exit status 1
expected unqualified-id before '.' token
please help Dx
My humidity sensor shows the same reading 95% ...its not changing...temp sensing is ok...what might be the problem?
Audio is too low to hear after about1:30
This is an older video, our new ones should have better audio :) Make sure to check out our more recent ones and Thanks for watching!
and image is also very fuzzy. can't read code
Any possibility to redo with your new mic... Anyway, I think the youtube subtitle generation works well enough if its not in your near term plan
Also link to the actual tutorial, not just a general page.
thank you !! good video
Thank you Thank you Thank you Thank you Thank you Thank you So much
thank's a lot it work like a charm,
+Vicreo Legarreta Glad it helped :) thank you for watching!
Why did it start at 12 degrees C and go up to 19 so fast?
Works but it turns out my sensor does not work :(
Hi there...I am having two problems and I hope someone can help me as soon as possible. I did everything in that video but when I took the measurements, they are all -999. And the other problem is that my humidity sensor overheats soooo much to the extent that one time it started to melt, I mean the plastic blue part of it. Help, please!
same
Something is wrong here.. mine is overheats and melt too...
Try a resistor maybe
Use a resistor between the Voltage and the Data Pin to stop it from melting
this gives a nice overview for dht11
www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/@@sahandeepdas3627
also has a circuit diagram that shows how to put the resistor (if you scroll down)
(im a beginner so sorry if this was obvious to everyone except me^^)
Why a0 used Insted of Digital pin
can you show us how to transmit this data wirelessly? Perhaps using a bluetooth module or something....
thanks dude!!
wokwi.com/arduino/libraries/DHT-sensor-library if this seems interesting, pls give a like and visit wokwi.com
all code was dump...output does not show...what to do???
SAME HERE BRO
It worked fine.
can program an arduino but cant get volume right on a video. maybe cc will work
sir how do i download the library and sketch as clicking on the link pops up just another window with tutorial not any download link !!!!?
#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
");
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()
As it is a digital sensor, you should use a digital input, not an analog ;-)
Digital Pin 2 on this example program works
/*
Board int.0 int.1 int.2 int.3 int.4 int.5
Uno, Ethernet 2 3
Mega2560 2 3 21 20 19 18
Leonardo 3 2 0 1
Due (any pin, more info arduino.cc/en/Reference/AttachInterrupt)
*/
#include
int idDHT11pin = 2; //Digital pin for comunications
int idDHT11intNumber = 0; //interrupt number (must be the one that use the previus defined pin (see table above)
//declaration
void dht11_wrapper(); // must be declared before the lib initialization
// Lib instantiate
idDHT11 DHT11(idDHT11pin,idDHT11intNumber,dht11_wrapper);
void setup()
{
Serial.begin(9600);
Serial.println("idDHT11 Example program");
Serial.print("LIB version: ");
Serial.println(IDDHT11LIB_VERSION);
Serial.println("---------------");
}
// This wrapper is in charge of calling
// mus be defined like this for the lib work
void dht11_wrapper() {
DHT11.isrCallback();
}
void loop()
{
Serial.print("
Retrieving information from sensor: ");
Serial.print("Read sensor: ");
//delay(100);
DHT11.acquire();
while (DHT11.acquiring())
;
int result = DHT11.getStatus();
switch (result)
{
case IDDHTLIB_OK:
Serial.println("OK");
break;
case IDDHTLIB_ERROR_CHECKSUM:
Serial.println("Error
\tChecksum error");
break;
case IDDHTLIB_ERROR_ISR_TIMEOUT:
Serial.println("Error
\tISR Time out error");
break;
case IDDHTLIB_ERROR_RESPONSE_TIMEOUT:
Serial.println("Error
\tResponse time out error");
break;
case IDDHTLIB_ERROR_DATA_TIMEOUT:
Serial.println("Error
\tData time out error");
break;
case IDDHTLIB_ERROR_ACQUIRING:
Serial.println("Error
\tAcquiring");
break;
case IDDHTLIB_ERROR_DELTA:
Serial.println("Error
\tDelta time to small");
break;
case IDDHTLIB_ERROR_NOTSTARTED:
Serial.println("Error
\tNot started");
break;
default:
Serial.println("Unknown error");
break;
}
Serial.print("Humidity (%): ");
Serial.println(DHT11.getHumidity(), 2);
Serial.print("Temperature (oC): ");
Serial.println(DHT11.getCelsius(), 2);
Serial.print("Temperature (oF): ");
Serial.println(DHT11.getFahrenheit(), 2);
Serial.print("Temperature (K): ");
Serial.println(DHT11.getKelvin(), 2);
Serial.print("Dew Point (oC): ");
Serial.println(DHT11.getDewPoint());
Serial.print("Dew Point Slow (oC): ");
Serial.println(DHT11.getDewPointSlow());
delay(2000);
}
...how do I code a 5 sec delay DHT function to 1 second loop ...since 1second loop is printing inaccurate temperature reading...x2 the Celsius.....if corporates with 12c LCD ..Time Elapsed counter since PC bootup project
kindly suggest some temperature sensor which is made up of that materiel which cant b melt because in my project sensor is directly touch all the time with fire
my dht11 sensor is reading 0 for everything. Do you know why this might be?
You should probably use another pin connection. I suppose you got 3 pins. (Left to right: Analog input - 5V - Ground)
I had the same error and that helped me. Thanks!
David Hawiger you're welcome :)
Plug the output into digital pin 2 and use this program. Not mine i just got it working with this example program
/*
Board int.0 int.1 int.2 int.3 int.4 int.5
Uno, Ethernet 2 3
Mega2560 2 3 21 20 19 18
Leonardo 3 2 0 1
Due (any pin, more info arduino.cc/en/Reference/AttachInterrupt)
*/
#include
int idDHT11pin = 2; //Digital pin for comunications
int idDHT11intNumber = 0; //interrupt number (must be the one that use the previus defined pin (see table above)
//declaration
void dht11_wrapper(); // must be declared before the lib initialization
// Lib instantiate
idDHT11 DHT11(idDHT11pin,idDHT11intNumber,dht11_wrapper);
void setup()
{
Serial.begin(9600);
Serial.println("idDHT11 Example program");
Serial.print("LIB version: ");
Serial.println(IDDHT11LIB_VERSION);
Serial.println("---------------");
}
// This wrapper is in charge of calling
// mus be defined like this for the lib work
void dht11_wrapper() {
DHT11.isrCallback();
}
void loop()
{
Serial.print("
Retrieving information from sensor: ");
Serial.print("Read sensor: ");
//delay(100);
DHT11.acquire();
while (DHT11.acquiring())
;
int result = DHT11.getStatus();
switch (result)
{
case IDDHTLIB_OK:
Serial.println("OK");
break;
case IDDHTLIB_ERROR_CHECKSUM:
Serial.println("Error
\tChecksum error");
break;
case IDDHTLIB_ERROR_ISR_TIMEOUT:
Serial.println("Error
\tISR Time out error");
break;
case IDDHTLIB_ERROR_RESPONSE_TIMEOUT:
Serial.println("Error
\tResponse time out error");
break;
case IDDHTLIB_ERROR_DATA_TIMEOUT:
Serial.println("Error
\tData time out error");
break;
case IDDHTLIB_ERROR_ACQUIRING:
Serial.println("Error
\tAcquiring");
break;
case IDDHTLIB_ERROR_DELTA:
Serial.println("Error
\tDelta time to small");
break;
case IDDHTLIB_ERROR_NOTSTARTED:
Serial.println("Error
\tNot started");
break;
default:
Serial.println("Unknown error");
break;
}
Serial.print("Humidity (%): ");
Serial.println(DHT11.getHumidity(), 2);
Serial.print("Temperature (oC): ");
Serial.println(DHT11.getCelsius(), 2);
Serial.print("Temperature (oF): ");
Serial.println(DHT11.getFahrenheit(), 2);
Serial.print("Temperature (K): ");
Serial.println(DHT11.getKelvin(), 2);
Serial.print("Dew Point (oC): ");
Serial.println(DHT11.getDewPoint());
Serial.print("Dew Point Slow (oC): ");
Serial.println(DHT11.getDewPointSlow());
delay(2000);
}
Can u help for me ?
I try make a ATM machine ( software process).In serial port just read one time only .But i need to read more time in one loop ( for to enter the password and the select the account types etc...)
Sorry can you help me? I'm using a nrf24l01 for arduino, but is very complicated, I don't understand very good the English manuals I can't use it, I only need send hello from arduino nano and receive it in arduino mega, but I can't , you know how make a simple code for transmission? Thanks for yours videos are very amazing!!
If you want to help me to compile a sensor humidity and temperature DHT22 on Arduino mega 2560
thanks
thanks bro, it's work! :D
Hello. Is it normal that the humidity sensor is getting hot? What is its operating temperature?
Hi !
Thanks for the tutorial. I got an error
DHT11:8: error: 'dht' does not name a type
Make sure the DHT library is uploaded and that you select it from the already uploaded libraries before you compile+upload the code to the Arduino.
can you please keep the DHT library plzzzz
me too
my library doesn't work with the line
#include "DHT.h"
or #include
but works with #include
or #include "dht.h"
the name is case sensitive
@@lukemagdalin6169 thanks
dhth say me no find in libreries
hii i want to apply my own temparature formula on DHT.temparature so i assigned to a variable Vo = DHT.temparature but its not working can u suggest some solution
I did everything right but my arduino keeps outputting 0 on both temperature and humidity. What can I do?
same with me but i dont know whats wrong either
did you ever figure out why the output was 0? I keep getting 0 for my outputs.
for me .. it was bcz the wiring was wrong .. my sensor had 3 pins the first from the left is Analog input and the middle one was 5v and the right one was ground
yes thanks for your help is working
Good vid but please fix volume (balance) and repost.
my sensor is just giving 0.0 value please help
Just getting 0 readings for both humidity and temp. Is it likely a faulty sensor? I've tried loads of different dupont wires but still the same results
wokwi.com/arduino/libraries/DHT-sensor-library try your code here.
how did you manage to fix this? i am getting the same 0 reading
same
i am having this error..
please help
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
Hello brainy how do i make it so it takes the highest temp/humidity and lowest?
You have help me greate
humidity works but temp stays at 28 :(
how can i set up my own using windows operating system not arduino and DHT11
pls help, when i connect the 5v pin when ground is connected ,my arduino turns off (disconnects from my computer) and i am not able to upload the code and when i connect to 3.3v so it dosnt turn off but it doesn't work, pls help as fast as you can
thanks in advance
im not sure, but you should try to switch the pins. The same have happened to med with another component.
@@oliverstvold7397 thanks for the help but that was 2 years ago and the problem with me was i put the sensor and pins horizontally on the breadboard so all the Arduino pins were connected with each other which led to a short circuit (i know that's dumb)
Thank you so much
Great Job
+Jay Zelsmite Thank you and thanks for watching!
it works but how to connect a lcd screen to it `?
icludo_temp:4: error: 'dht' does not name a type
dht DHT;
^
C:\Users\kakasharma\Documents\Arduino\icludo_temp\icludo_temp.ino: In function 'void loop()':
icludo_temp:18: error: expected unqualified-id before '.' token
DHT.read11(dht_apin);
^
icludo_temp:21: error: expected primary-expression before '.' token
Serial.print(DHT.humidity);
^
icludo_temp:24: error: expected primary-expression before '.' token
Serial.print(DHT.temperature);
^
exit status 1
'dht' does not name a type
i have this error sir help me on this at time of compiling
Any chance you know if this would work with MIT App inventor 2, I'm trying to temp, humidity, gps, and prewritten message send to someone as a project. Thanks to anyone that can guide me to any kind of solution.
Tutorial - download a library - done
sir can u please tell me the connections when arduino mega 2560 connected.
How do I change this to Fahrenheit?
Datasheet shows we need to use pull up resistor for DHT11, Can you explain it? Thanks
there is a 1k ohm resistor on the module
Anyway to calibrate this sensor ?
I've got a project to read humidity from DHT11 using multimeter. I believe I should convert the digital output of DHT11 into analog, but I am lost and dont have anymore ideas. Could you help me ? Thanks.
+Riszky Mf Can't help you with that one my friend, maybe someone here can. Thanks for watching!
The folder has different codes than this one showed on the screen. will someone help me?
Figured it out
Sir can you please tell us the pin connections for Arduino Mega 2560 and how to display the temperature and humidity values on 1.8 TFT st7735
I've made a newer video about the DHT11 and DHT22, check it out here: ruclips.net/video/8tfj0ZfADcE/видео.html and also here's the tutorial page for more information:www.brainy-bits.com/dht11-and-dht22-with-arduino/ Hope that helps and thanks for watching!
it says i need Adafruit_sensor may you help it would be appreciated
Gracias por el video!!
I saw some other websites explaining this and they have used a resistor(10k ohm) between the VCC and Data pins, is that necessary to use as you haven't done it hence the doubt
No meed, the DHT11 has 1k pull-up resistor onboard.
Please give direct link to this project of your website
Hi bro getting error in program..... 1 row getting error DHt.h
hi. its giving the output zero, can anyone help me?
Video is very blur to c codes...can someone help me..
Hi can you send me a code please