Arduino Tutorial 50: How to Connect and Use the DHT11 Temperature and Humidity Sensor

preview_player
Показать описание
You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:

In this lesson we show you how to measure temperature and pressure using the DHT11 sensor. The needed library does not come with the arduino download, but the video shows you how to intall the needed library.

You can get the kit I am using for this series at the following link:

This is a heads up that in lesson 51, you will be able to have a much more practical and elegant solution if you use an arduino nano instead of the uno, which we have been using. Go ahead and get ready for lesson 51 by picking up a nano here:

As projects get more complicated in these lessons, you guys really need to get a set of breadboard jumper wires which allow you to make neater connections on the board in your projects. You can pick a pack of these wires up here:

In addition as projects get more complicated, you are going to need a bigger breadboard. This is a reasonable one here:

Check out all the great Free educational resources at our WEB site HERE:

#Arduino
Рекомендации по теме
Комментарии
Автор

PS -- I'm 78, retired Chemistry instructor, and decided to learn electronic basics as a Covid relief. Never too old to learn new things. From one instruction to another, I find your presentations very well thought out. Thank you !

dbhamilton
Автор

Another great video! Two comments.


1. An alternate way to install the DHT11 library is to use the Arduino IDE. (I'm using version 1.8.10 of the IDE.) From Tools->Manage libraries... enter "dht" in the "Filter your search" box; after about 1 second, you will see some results (I see "DHT sensor library by Adafruit Version 1.3.8" as the second entry). If you put your mouse in the area for an entry, an Install button appears. Clicking it installs the library. Done! Note: the same version, 1.3.8, appears at the top of the list when doing the search you describe in the video.


2. At 17:00 you noticed that "readHumidity" did not highlight correctly. This is due to something not being right in the "keywords.txt" file that is in the DHT library folder. I found the following problem and fix that describes what is probably wrong:





I suspect that if you use a hex editor to look at the readHumidity line in your keywords.txt file, you will see that there is not a tab (0x09) character between readHumidity and KEYWORD2. See the keywords.txt snippets below.



Note: In my installed 1.3.8 keywords.txt file, tabs are where they should be. Entering readHumidity() (and readTemperature()) in a sketch produces highlights as expected.



 I just downloaded the "1.3.4" version of the DHT library (supposedly the same one you did when you created the video), unzipped it, and looked at the keywords.txt file line for "readHumidity". It does have 0x09 between readHumidity and KEYWORD2. However, when I look at the timestamp for the keywords.txt file, I see "30 April, 2019", which is after the release date of 2019-02-18, so this file may not be the one you were using! Looks like Adafruit slipped in changes after the release date.


Here's a snippet of what I see in the 1.3.4 keywords.txt, both in ASCII and in hex. All instances of lowercase 'b' in the ASCII snippet represent (what appear to be) spaces. In the hex snippet, the "spaces" are seen to be tabs (0x09), as they should be. The hex output shows 16 bytes of output per line; the hexadecimal numbers are the byte values--4 groups of 4 bytes; the text
at the end of each line is the corresponding ASCII; periods represent unprintable characters. The periods on the first line of the ASCII snippet skip over the beginning of the text line up to the point it matches the corresponding hex output.



begin ASCII snippet

readHumiditybbbbKEYWORD2
readbbbbKEYWORD2
end ASCII snippet

begin corresponding hex snippet
6578094B 4559574F 5244320A 72656164 ex.KEYWORD2.read
48756D69 64697479 094B4559 574F5244 Humidity.KEYWORD
320A7265 6164094B 4559574F 5244320A 2.read.KEYWORD2.
0A .
end corresponding hex snippet



I'm guessing that you have a space (0x20) between Humidity and KEYWORD2.


While I thoroughly enjoyed the video and working on the sketch for Lesson 50, I think I had more fun looking into the keyword issue!

johnganci
Автор

Paul, I am a 67 year old carpenter. I just recently got turned on to the exciting world of electronics, arduinos, robots and all the rest. I regret having missed all this earlier in my life.


But I just wanted to tell you how much I appreciate your tutorials. They are excellent in every regard. Everything is top drawer. Your personal teaching style, the graphics, the sound and lighting, the topics covered and the pace all make me keep coming back for more. Well done man! Keep up the good work!

socorrotravassos
Автор

the voice of Paul is music to my ears :)

theteenengineer
Автор

I got it working first time. Then I changed the LCD to one with Serial input and using a sensor shield to tidy up things. Got it working; BOOM! I really appreciate your willingness to share. With a background in Electrical Engineering and Computer Science, I spent 32 1/2 years in the technical support and technical training area of Toyota Motor Company; most of it training Toyota dealership technicians. I can appreciate all the time and effort that you put into each of these activities. Great job and keep up the good work!

klrwhizkid
Автор

Paul, you are an educator and mentor. If I helped half as many people as you have I would be happy. Luckily I did have teachers like you in school. You make learning fun and interesting and I hope you never lose interest in teaching.

devtest
Автор

My 9yr old daughter and I walked through this and had a great time watching you. Thanks! I like graphing out the temps.

nachoKrinkle
Автор

When I saw that the Nano had bluetooth capability, I got really excited for the projects that lay ahead. Thank you for all you do Paul! these projects have really opened my eyes to some of the systems i have been using all my life... eg. the automatic door at the grocery store, the thermostat on the wall, fans... Almost every time I do a project, I can see it's application in the real world. This has been very enjoyable. I plan to keep doing the lessons!

chrisb
Автор

I can’t tell you how much I appreciate your walking through the actual process and the comments that provide further info to orient me!

williamwachter
Автор

Hey Paul! Loving the tutorials, i'm an arduino veteran but stepping back into it after years and this has been a great refresher. PLEASE make sure you update your link on the elegoo kit, it looks like they may have made a new product listing so none of us can support you by following the link. I'd suggest updating it on all your video descriptions so you can get the well deserved referral credit.

bn
Автор

Okay, I've done the homework for this lesson. My Arduino kit did not come with the DHT sensor and Nano and so both had to be ordered separately. The LCD came in the Arduino kit came with an I2C module embedded with it and that eliminated the extra wiring needed; however it needed for an extra library to be downloaded and installed. The Nano had some compatibility issues and after some research came to understand that some of these foreign manufactured items needed a separate driver to be downloaded and run. The DHT sensor too required an additional "Adafruit sensor master library" as well as the "DHT sensor library" installed.
I coded the lcd to display "Humidity" and its value in the first screen and after 2 seconds the display clears and shows "Temperature" in the 1st line and the values in Celcius and Farenheit in the 2nd line. Enjoyed the challenge !!!

sssagc
Автор

Got everything to work fairly quickly on this assignment. I discovered the sq() and PI functions which made the formula for the area much easier and more accurate. The rest was just utilizing what I learned in the last tutorials. Easy to learn when you have a great teacher. Thanks for the lessons. I also got the humidity and temperatures to display without any real issues. The biggest problem is fitting everything to the display.

adamcurtice
Автор

Sir, Great video. Just an update. I had got nan output. Trapped output in long variable. Got -2147483648 as output. Finally loaded Files>Examples >DHT sensor library. Uncommented DHT11. Commented DHT22. Compiled & loaded. Got correct output.
Thanks for great videos. Your explanations are excellent. When ever possible, please tell us about arduino board. There are so many videos on internet, but your style is second best to none.

blackbox
Автор

Great lesson. My out put was so scrambled it was driving me crazy until I saw it was plugged into pin one but everything going well now. Thanks Paul.

opalprestonshirley
Автор

I have followed and enjoyed all of your videos in this series so far. I followed your explanation on installing the DHT library and I received an error message "file not found". After some research, I had to also download the ADAfruit_Unified_Sensor zip file as well. Now all is working.

carlkoplinmd
Автор

Assignment is completed!
Did it with the recommended wires and bigger breadboard, and it feels and works so much better!
Waiting for my Arduino nano!
Thank you very much for your amazing tutorials!

ysbcyhz
Автор

For library installation you can just go to sketch>include libraries > add ZIP. Library without extracting the zip file .
And by the way thanks for your tutorials Paul ;) keep up the great work.

couteaghajarry
Автор

Paul, you have single-handedly revived my conviction to complete my project. You're a legend, sir.

chrisvandergriff
Автор

Thank you for walking us through instead of just opening a library example. Now I understand how to use and code for the sensor, instead of copying it. :D

cesaramaral
Автор

Hello Mr. Macwhorter, am Raymond from Ghana-west Africa. I started learning Arduino Programming by watching your videos and when my desire and hunger for it increased, I went online to look for books on it and have actually finished learning one of the books. Your videos have been very inspirational and fundamental to my increasing taste for Arduino.
I have watched all your videos on Arduino from start to finish just that, I don't watch it online, I download and practice so you may not see me responding to your "secret world" challenge.
Due to my increasing desire to know more, I have come across some options that may be helpful;
1. You know, for the equations that you derive to help match some group of values with the other, there is a function in Arduino called "map()" and I do think it can be used inplace of the equations.
2. Secondly, for the buzzers, there is also a function called "Tone()" and also "noTone" that can be used to control the buzzer.
So I am humbly suggesting this suggestions so it could be researched to see how helpful it could be in the making of subsequent videos.
Mr. Macwhorter, keep up with the good work you are doing because, you are actually helping someone somewhere indirectly Usher into the world of programming and the technologies that come with it.

I personally want to ask if you would start Arduino video tutorials on wireless devices.
Thank you sir.

Contact: +233542924336

raymondsenyo