arduino and dht11 output to lcd module free sample
DHT11 is a Humidity and Temperature Sensor, which generates calibrated digital output. DHT11 can be interface with any microcontroller like Arduino, Raspberry Pi, etc. and get instantaneous results. DHT11 is a low cost humidity and temperature sensor which provides high reliability and long term stability.
In this project, we will build a small circuit to interface Arduino with DHT11 Temperature and Humidity Sensor. One of the main applications of connecting DTH11 sensor with Arduino is weather monitoring.
We will see the circuit design of DHT11 interfacing with Arduino. The DHT11 Humidity and Temperature sensor comes in two variants: just the sensor or a module.
The main difference is that the module consists of the pull – up resistor and may also include a power on LED. We have used a module in this project and if you wish to use the sensor itself, you need to connect a 5K Ω pull – up resistor additionally.
Coming to the design, the data pin of the DHT11 Sensor is connected to the Pin 11 of Arduino. A 16 x 2 LCD display is used to display the results. The control pins of LCD i.e. RS and E (Pins 4 and 6 on LCD) are connected to pins 4 and 5 of Arduino. The data pins of LCD i.e. D4 to D7 (pins 11 to 14 on LCD) are connected to pins 0 to 3 on LCD.
NOTE: For ease of connection, we have connected the DHT11 Sensor Module at the ICSP pins of the Arduino as it provides adjacent VCC, DATA and GND pins. This type of connection is not necessary and you can connect the data pin of sensor to normal Digital I/O pins.
DHT11 is a part of DHTXX series of Humidity sensors. The other sensor in this series is DHT22. Both these sensors are Relative Humidity (RH) Sensor. As a result, they will measure both the humidity and temperature. Although DHT11 Humidity Sensors are cheap and slow, they are very popular among hobbyists and beginners.
The DHT11 Humidity and Temperature Sensor consists of 3 main components. A resistive type humidity sensor, an NTC (negative temperature coefficient) thermistor (to measure the temperature) and an 8-bit microcontroller, which converts the analog signals from both the sensors and sends out single digital signal.
DHT11 Humidity Sensor consists of 4 pins: VCC, Data Out, Not Connected (NC) and GND. The range of voltage for VCC pin is 3.5V to 5.5V. A 5V supply would do fine. The data from the Data Out pin is a serial digital data.
The following image shows a typical application circuit for DHT11 Humidity and Temperature Sensor. DHT11 Sensor can measure a humidity value in the range of 20 – 90% of Relative Humidity (RH) and a temperature in the range of 0 – 500C. The sampling period of the sensor is 1 second i.e.
Also, the length of the cable can be as long as 20 meters. The data from the sensor consists of integral and decimal parts for both Relative Humidity (RH) and temperature.
8 – Bit data for integral RH value, 8 – Bit data for decimal RH value, 8 – Bit data for integral Temperature value, 8 – Bit data for integral Temperature value and 8 – Bit data for checksum.
In order to check whether the received data is correct or not, we need to perform a small calculation. Add all the integral and decimals values of RH and Temperature and check whether the sum is equal to the checksum value i.e. the last 8 – bit data.
This value is same as checksum and hence the received data is valid. Now to get the RH and Temperature values, just convert the binary data to decimal data.
A simple project is built using Arduino UNO and DHT11 Humidity and Temperature Sensor, where the Humidity and Temperature of the surroundings are displayed on an LCD display.
After making the connections, we need not do anything as the program will take care of everything. Although there is a special library for the DHT11 module called “DHT”, we didn’t use it. If you want to use this library, you need to download this library separately and add it to the existing libraries of Arduino.
The program written is based on the data timing diagrams provided in the datasheet. The program will make the Arduino to automatically read the data from the sensor and display it as Humidity and Temperature on the LCD Display.
Hello friends! Welcome back to ElectroDuino. This blog is based on DHT11 Temperature and Humidity Sensor Arduino Code with LCD Display. Here we will discuss Introduction Temperature and Humidity Monitoring System, Circuit diagram, Working and DHT11 Temperature and Humidity sensor Arduino Code with LCD Display.
In the previous blog posts, we were learning about the “DHT11 Temperature and Humidity Sensor Module” and “Interfacing DHT11 with Arduino”. In this project, we will discuss how to make a Temperature and Humidity Monitoring System. Where we will print the Temperature and Humidity value on a 16×2 LCD display using DHT11 and Arduino. DHT11 is the cheapest humidity and temperature sensor, it provides high reliability and long-term stability output. This is a very small and portable Temperature and Humidity Monitoring system so we can use it at home, office, school, etc. places. It gives us the Temperature and Humidity value of around it 24 x7. Here we will build this system and learn how to write the DHT11 Temperature and Humidity Sensor Arduino Code with LCD Display.
Before writing the Arduino Code we need to install two Libraries in our Arduino IDE Software, one is ” dht.h ” DHT11 sensor Library and Another one is “LiquidCrystal.h” 16×2 LCD Display Library You can Download the Library file by click on the Download Button.
Here is the simple code that will make it work correctly. I had the same issue and just figured it out. I put some comments about the changes I made and stuff I figured out…. Make sure you have the 3 libraries that are noted “#include”
It’s a low cost digital temperature and humidity sensor module which based on the new DHT11 sensor. The Grove DHT11 sensor requires only one I/O pin for the communication with the master device.
The Grove DHT11 temperature & humidity sensor uses the upgraded version of DHT11. In this version, resistive humidity components is replaced by capacitive humidity components, temperature and humidity measurement ranges are wider and temperature resolution is higher.
Seeed Studio provides a nice open source library for their LCD module which can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “grove lcd” and install the one from Seeed Studio).
They (Seeed Studio) also provide a library for their Grove DHT11 sensor but I recommend to use the one given by Adafruit Industries which can be installed also through library manager (in the search box write “dht sensor” and choose the one written by Adafruit) or manually, download links are below:
I have the dht11 reading and printing to lcd and serial monitor.I have the dht11 controlling two relays one for temp and one for humidity.When the relay turns on the dht11 stops sending readings and freezes and stops reading? Any way I can fix that ?thanks
From what I’ve read from the datasheet it can’t be read from more than once every 2 seconds. Changing the delay to 2000 cleared the issue up right away for me
The output is to the serial monitor, unless you have connected an LCD. The video will show you how to open the serial monitor if you don’t already know how to.
A quick question tho, do you have a tutorial on how to connect this to a wireless transceiver?? also in theory could i connect more then one humidity detector to an arduino in order to detect humidity from more then one spot? Thank you again and i’ve subscribed!
Hi Jose, you can definitely connect more than one sensor to a single Arduino. You would basically duplicate the code, and have a separate pins read the data from each sensor. As for connecting them to a wireless tranceiver, I’m sure it’s possible, but you would probably need to use another microcontroller as a hub to transmit the data. I haven’t tried it yet though, so don’t take my word for it!
Hello, I built my first arduino project (measuring the room temperature and humidity with the DHT11) during Christmas holidays. The readings of the values were shown on the screen of my laptop. The measured room temperature was correct, but the measured humidity was much too low (about 20%RH). What can be the reason for ithe low humidity? And how can the sensor (if needed) be recalibrated?
I haven’t tried connecting multiple sensors, but it should be fairly easy. You would just duplicate the code and use a separate pin to read the data for each sensor
Probably not, since the signal is at the same voltage as Vcc. If you swap the Vcc and signal pins, the output will just read -999.00 for temp and humidity.
vcc is the left one, signal the middle one and ground is the round one, in case of a 3 pin DHT11. the diagram above is not right. i was getting the same problem here.
IN MY CASE IN THE DHT-11 BOARD WRONG RESISTOR WAS SOLDERED, WITHOUT KNOWING TAT I HAD TRIED ALL STUFF, GIVEN 10K PULL UP ADDITIONALLY.. DIDN’T WORKED FINALLY TRACED THE RESISTANCE BETWEEN PINS IT WAS 5 OHMS.. THEN BACK TRACED & REMOVED TAT & PULLED UP WITH 10k SOLVED MY ISSUE.. GUESS U TOO HAVE THE SAME ISSUE.. JUST CHK OUT..
The diagram is correct for most three pin DHT11 modules. Depending on the manufacturer, the pins on the PCB might be different though. The pins should be labelled with S for signal and “-” or “GND” ground.
Then i understood, that the breadboard has not 2 power circuits (top and bottom), but four (top left, top right, bottom left, bottom right). This is the thing which was never said on youtube)
See the section “Output Humidity and Temperature Readings to an LCD Display” on a desktop… If you are viewing it on mobile, the full code might not display. Hope this helps
Can you guys help me in this. All I want is to design a circuit that could predict a rainfall or water and send a message to the user to his phone.Also keeping in mind about the humidity and temperature factors.
It sounds like you want to control the heater with the DHT11 and have the readings output to an LCD too… You can use the DHT11 to control the signal to a 5V relay, similar to what’s done in this article: https://www.circuitbasics.com/build-an-arduino-controlled-power-outlet/
Then you just need to add the code to initialize the LCD, include the LiquidCrystal library, and change the “serialprint()” functions to “lcd.print(). We have another article on setting up an LCD on the Arduino if you need help with it: https://www.circuitbasics.com/how-to-set-up-an-lcd-display-on-an-arduino/
i didnt have any trouble interfacing the arduino, lcd and the dht11 sensor and my codes were quite right since when i run it, nothing’s odd in the output. but when i connect the relay,in which an ac device is connected, as an output that turns on after a couple of minutes, the temperature and humidity dislayed on the lcd becomes odd, like chinese and numbers, after some time. i checked my codes but i cant figure out whats wrong with it.
please help me.. i won’t get Alarm temperature and humidity..and show in lcd display 16×2.. and changeing temperature, humidity alarm set point HOW IS DO… PLEASE HELP ME.
So curiously, I had already downloaded and installed the latest version of DHTLib (v0.1.21) versus the older version (v0.1.14) that is provided here. And I kept getting 0.00 values for the temp and humidity readings as Alex reported on April 20, 2016 in a posting above. I scratched my head for a while until I remembered I had the newer version of the library installed. So I removed that, installed the older v0.1.14 version, and bam, lo and behold, I started getting real values back. So this may be the same problem that Alex had, too.
I’ve looked at the brief changelog history in dht.cpp file, and I’m seeing no obvious reason that might allow v0.1.14 to work, but not the newer v0.1.21. Anyone have thoughts about this?
Any comments about DHTLib v0.1.14 vs. v0.1.21, and why this simple Arduino sketch works in the former, but not the latter? The brief history in the cpp file header for v0.1.21 looks like it took care of a few issues so my first instinct is to use that, but again, it results in all zero readings. Anyway, if no comments, well, I’ll have to take a look through the diffs between the two versions to see what might be causing the issue.
vcc is the left one, signal the middle one and ground is the right one, in case of a 3 pin DHT11. the diagram above is not right. i was getting the same problem here.
The diagram is correct, but your particular DHT11 could have a different pinout depending on the manufacturer. The DHT11 I used is from Keyes, what type do you have?
Are you using the four pin DHT11? If so you’ll need to put a 10K Ohm resistor between the Signal line and Vcc. I just added another diagram to the post to make it a bit clearer. That may be causing your issue.
Thanks a lot, may you please help me out, I am using a Mega 2560 with a DHT11 sensor, my problem is that both temperature and humidity reading is just being reed as 0.00 and they are not changing. What might i be doing wrongly, I have even tried the code that accompanies these tutorials
This seems like a really simple setup, but I’ve been having a lot of trouble setting this up. Have there been changes to this library? I have downloaded it, but arduino still refuses to recognize dht or any of the related functions, like temperature/humidity. It had a lot of trouble with line 3, dht DHT;. Any advice?
Yes, the library was updated recently (v. 0.1.21) and doesn’t seem to work. If you download the zip file I put in the post, it should work. It’s the older version 0.1.14.
Hi, you mentioned you added a piece of code to show the “degree” symbol,” lcd.print((char)223)”, can you tell me if the number 223 is from the ASCII table.
vcc is the left one, signal the middle one and ground is the right one, in case of a 3 pin DHT11. the diagram above is not right. i was getting the same problem here.
i am doing fire alarm system using dht and lcd and GSM sim800l how can i make argument to send message from gsm if the sensor reading is higher that the set temp and how to declare it thanks for your response
After uploading a code my dht-11 keeps reading zero ‘0’ for both humidity and temperature as the output on my serial monitor. please what could be the problem?
I am very happy to inform you that I fixed successfully the temp and humidity project with LCD display. I would like to subscribe but cannot find the link.Many thanks
C:\Users\mhine\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/Arduino.h:227:63: error: cannot convert ‘volatile uint32_t* {aka volatile unsigned int*}’ to ‘volatile uint8_t* {aka volatile unsigned char*}’ in initialization
Hi. I have the same issue with the same board. Did you get it to succeed in the end? I would be interested, but I feel that it may be a compatibility issue with a 3rd-party board. I have tried the exact code with other Arduinos that I have and it works just fine.
I get this same error when I try to use the Arduino 101 instead of the Uno. I think the library doesn’t support the board. I would try finding a different DHT library, there are several others out there.
I Have issues with the Arduino recognizing the file dht.h. Was told no such file exist, meanwhile I have uploaded the zip file into the Arduino IDE, which showed in the file directory.
Did you use the library in the zip file from the post, or did you download it from the Arduino.cc page? Version 0.1.21 has some issues and doesn’t appear to work. The zip file in the post is version 0.1.14, and it does work. Also, are you using the Uno, or another board? I couldn’t get the library to work on my Arduino 101…
In this language, does declaring an object variable (as in “dht DHT;”) automatically instantiate it? I am more used to other languages that would need to follow the declaration with something along the lines of “DHT = new dht(params, for, constructor);” Does this normally go without saying in C++, or is this something the Arduino environment automatically adds at the preprocessing** stage?
**: If not “preprocessing,” then whatever else Arduino parlance calls the process of converting/expanding the “Processing” (??) or “Wiring” (???) code into standard C/C++ ????
hey can you pls help me how to use rf module with the above project. i am using two arduino uno, DHT11, LCD, RF transmitter and receiver. please can u give me a code to display temperature and humidity on the receiver side lcd…
to start the cummunication the ardduino will give LOW to the data line,after the dht finished the transmition of data,the line will return to HIGH,IS THAT CORRECT???
Thanks for the mod, skyfox66. Being in America among the holdouts, I am of course still using degrees F. After days of struggling and searching I finally got this combination of parts and code to work right. (After I found this website).
I connected the LCD and the DHT11 and copied and pasted the code. It uploaded and then I look at my LCD and all I see are white boxes on the top of the display. Can anyone help me?
I copied this exactly and got it to display temperature and humidity, but it flashes -999 for temp and -999 for humidity every other second. For example, it will display correct readings for one second, then the -999 for both readings the next second.. Flashing between the two. Any ideas why it might be doing this. I have been playing with the code, rechecking pins, etc, but I cant seem to pinpoint the problem. Any input is appreciated.
hello, i need some help, i want code for, if i m sending message from mobile (e.g. ABC) to arduino via gsm module then the values of temperature and humidity receiving specific number
I have arn Arduino y module that I am using to trgger an extractor fan in a shower. I was wondering whether this humidity sensor could be used to simply close the 5v circuit so teh fan runs on until teh humidity is below a set vaue. Is that possible simply?
Hi.recently i conduct sensor circuitry.in source code,i notice that it use \xF8 to display temperature in degree celcius.what is the function of that?
I followed the instructions exactly, wiring was good, code was an exact replica of that given. Everything was correct, but I got -999 error message every time. I was using a three pin sensor, triple checked my wiring against the diagram. I increased the delay time to 3000ms. I was definitely using the correct older version of the library. After throwing out the sensor thinking it faulty, I have since discovered that the diagram above is does not apply to every dht11, that there are some where the pins are in a different order.
What does this mean? in every other arduino program I can find that uses additional libraries, the library is called first, then the code goes straight on to initialising the variables and describing the setup. I have not been able to find any other mention of the library name mentioned twice like this. A few people have asked about this, with no answers given. I cant even search for it because I dont know what to search by.
Awesome website – every content is superb – We have a huge collection of branded Electronics product please have a look here https://webearnorg.blogspot.com/2018/05/electronics-supply-stores-near-me.html
Clear, informative and knowledgeable. Moisture from the air collects on the film and causes changes in the voltage levels between the two plates. This change is then converted into a digital measurement of the air’s relative humidity after taking the air temperature into account.
You will get 100% humidity if you put the sensor in water and it works. Use an SHT31-D breakout board to detect humidity and temperature. I’m sure you didn’t mean you are going to submerge the sensor. The SHT31-D is more accurate and easier to install and costs about the same as the DHT11 /22 both of which really aren’t accurate at all.
i have changed the sensor, checked voltages at each junction,switched pull up resistor, included the exact library available here but couldn’t get the accurate result,
Ine is set up exactly as you show. I get -999.00 for both humidity and temperature. I have 2 different sensors (both DHT11) and I get the same readings. I even set this up on an RPI 3B+ and the readings were similar. 1.0 temp and humidity. What am I doing wrong?
I’m a bit new to audrino and i started my first project. I found that this tutorial was the most comprehensive out there, which is awesome. One thing that i’m running into a bit of issue on is that im an “400 invalid_request” while attempting to import the DTH library. I was wondering if you could provide a little assistance to get pass this issue. Please see the full error message below.
I’m wondering if there’s a way to have this working intermittently? I want to moderate the humidity levels in food containers to prevent mould. If this was running off a battery would it last long enough?
I can not keep my display from blinking the temp and humidity values. It displays the value but blinks back and forth to -999.00. Thanks for the help I’m new
Your so awesome dude. I owe you a lot! Thanks for the tutorial dude. you’d help many people. keep going! God bless more power. Im from philippines ^_^
Still getting -999.00 on both temperature and humidity with LCD. If I connects ONLY DTH11 to Arduino with serial monitor it works fine, BUT if I connect it to LCD as described above it shows -999.00 In both LCD and serial monitor. It looks like it disables the DTH11 when connected to LCD. It does not work with dely(2000); or any other value.
i don’t know why but the LCD shows me white circles and within them the text is written also the temp and humidity are a constant 0 even with the serial monitor
It’s good idea for projects. I am thinking of building my own weather unit soon. Please can someone help me with a simulation circuit that will show the response graphs of dht11 for temperature and humidity
How would you configure Celsius to Fahrenheit when doing the LCD version? I read others commenting how with out the LCD but not with the code for using the LCD.
I’m looking to couple this humidity sensor with a 5V relay to actuate a small on/off valve depending on the humidity level. Essentially, I’d like valve to open when the humidity reading from the sensor goes above, say, 75%, and closes when the reading goes below 60%. Do you have any recommendations?
I am a hobbyist and has certain experience in electronics and wish to adopt programming. So kindly some one can help me to achieve the above goal with codes and probable sketches for the connections.Hope to receive a reply in this respect from your side.
HELLO, thank you for the big assistance. I’d like to share to u the screenshoot of my serial monitor output… Atleast let me show how it looks like & help me to debug. Big thanks to you
You have to adjust the wait time to less to count for the fact that the sensor Only gives an output for a small amount of time so play around with that to get it to work
Arduino UNO - LCD display and DHT11 sensor with temperarure and humidity measurement. When there is no datafrom the DHT11 sensor, the buzzer will be activated.
Welcome to ProteShea – in this project, we’re going to interface a DHT11 temperature and humidity sensor, and display the data on a 16×2 LCD. If you haven’t read
ProteShea, LLC is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Some links may be affiliate links, in which ProteShea, LLC earns a commission if you use that affiliate link. Please note that this is at no additional cost to you and helps us in creating more content.
Please see Project 9 on how to interface the 16×2 LCD in 4-bit mode. You should have pins 4, 6, and 11 – 14 of the LCD connected to Uno pins 2, 3, and 4 – 7, respectively.
The 20×4 LCD adds two extra rows and four extra columns per row compared to the 16×2 LCD. Similar to the 16×2, the 20×4 LCD uses the Hitachi controller so the commands and interfaces are the same. It also has the same 16-pin header, allowing you to unplug the 16×2 LCD and plug in the 20×4 without changing any wiring. The only thing we have to change is one line of code, lcd.begin(20, 4), which specifies the columns (first argument) and rows (second argument) of the LCD.
There are different types of DHT sensors such as the DHT11, DHT21, DHT22, DHT33, and DHT44. They all measure both temperature and humidity, but the difference lies mostly in their accuracy and sampling rate. For example, we show a side-by-side comparison in the table below of the two most popular DHT sensors, DHT11 and DHT22. The DHT22 has a better accuracy and range, but it has a slower sampling rate, it’s bigger in size, and double the cost of the DHT11.
To measure the temperature and humidity, a thermistor and a capacitive humidity sensor are used, respectively. The resistance of a thermistor changes with a change in temperature – as the temperature increases, the resistance decreases. For the humidity sensor, the resistance between the two electrodes changes with a change in humidity. Both of these changes in resistance are measured by the IC on the sensor and sent to the host via a 1-wire interface. Each sample consists of a 40-bit data packet.
We are using a 3-pin DHT11 sensor as shown in the image below. The pins are “+”, “OUT”, and “-.” The sensor can be supplied with both +5Vdc or +3.3Vdc – we’ll be supplying +5Vdc to it.
We are mounting the DHT11 sensor to the 2.54mm pitch section of Modulus with a right-angle (R/A) female header, as shown in the image below. Solder the 4-pin R/A female header to the edge of the board. Next, solder a 4-pin male header adjacent to the female header. Once you have the headers soldered on, flip the board over and make a solder bridge between the adjacent pins of the headers.
Wire-wrap the “+” pin to +5Vdc which is any of the pins in column 20 on the 4×26-pin breakout. Then wire-wrap the “-” pin to the GND vector just below the 4×26-pin breakout. Use a 12″ F/M jumper to connect the “OUT” pin to pin 8 of the Uno.
First, place the breadboard in the bottom storage compartment to limit the length of the jumper wires. You’ll need to supply +5V and GND to the power and ground rails on the breadboard by using the provided banana jack to test-lead clip cables. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno’s receptacle. Power up the FuelCan with the AC-DC power adapter.
Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. The first sketch is used with the 16×2 LCD. The second sketch is used with the 20×4 LCD. The DHT11 sensor is sampled every two seconds since sampling faster causes errors.
In this Arduino Tutorial we will learn how to use the DHT11 or the DHT22 sensor for measuring temperature and humidity with the Arduino board. You can watch the following video or read the written tutorial below for more details.
These sensors are very popular for electronics hobbyists because there are very cheap but still providing great performance. Here are the main specifications and differences between these two sensors:
The DHT22 is the more expensive version which obviously has better specifications. Its temperature measuring range is from -40 to +125 degrees Celsius with +-0.5 degrees accuracy, while the DHT11 temperature range is from 0 to 50 degrees Celsius with +-2 degrees accuracy. Also the DHT22 sensor has better humidity measuring range, from 0 to 100% with 2-5% accuracy, while the DHT11 humidity range is from 20 to 80% with 5% accuracy.
There are two specification where the DHT11 is better than the DHT22. That’s the sampling rate which for the DHT11 is 1Hz or one reading every second, while the DHT22 sampling rate is 0,5Hz or one reading every two seconds and also the DHT11 has smaller body size. The operating voltage of both sensors is from 3 to 5 volts, while the max current used when measuring is 2.5mA.
Ok now let’s see how these sensors actually work. They consist of a humidity sensing component, a NTC temperature sensor (or thermistor) and an IC on the back side of the sensor.
For measuring humidity they use the humidity sensing component which has two electrodes with moisture holding substrate between them. So as the humidity changes, the conductivity of the substrate changes or the resistance between these electrodes changes. This change in resistance is measured and processed by the IC which makes it ready to be read by a microcontroller.
A thermistor is actually a variable resistor that changes its resistance with change of the temperature. These sensors are made by sintering of semiconductive materials such as ceramics or polymers in order to provide larger changes in the resistance with just small changes in temperature.
The DHTxx sensors have four pins, VCC, GND, data pin and a not connected pin which has no usage. A pull-up 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 Board. There are some versions of these sensors that come with a breakout boards with built-in pull-up resistor and they have just 3 pins.
The DHTXX sensors have their own single wire protocol used for transferring the data. This protocol requires precise timing and the timing diagrams for getting the data from the sensors can be found from the datasheets of the sensors. However, we don’t have to worry much about these timing diagrams because we will use the DHT library which takes care of everything.
First we need to included the DHT library which can be found from the Arduino official website, then define the pin number to which our sensor is connected and create a DHT object. In the setup section we need to initiate the serial communication because we will use the serial monitor to print the results. Using the read22() function we will read the data from the sensor and put the values of the temperature and the humidity into the t and h variables. If you use the DHT11 sensor you will need to you the read11() function. At the end we will print the temperature and the humidity values on the serial monitor.
In this project, we are going to interface a DHT11 temperature and humidity sensor, and display the data on a 16x2 LCD. If you haven"t readProject 9for the Arduino Uno Rev3, please read that first because this covers how to interface a 16x2 character LCD in 4-bit mode. We will then swap out the 16x2 LCD for a 20x4 LCD to display the humidity and the temperature in Celsius, Fahrenheit, and Kelvin. The DHT11 sensor can be used for a weather station, weather balloon, drone, or greenhouse.
In our previous project, we showed you how to interface a 16x2 LCD to the Uno. You should have pins 4, 6, and 11 - 14 of the LCD connected to Uno pins 2, 3, and 4 - 7, respectively. You can either connect the LCD using a solderless breadboard or the Modulus Canister. An image is shown below with it connected to Modulus.
The 20x4 LCD adds two extra rows and four extra columns per row compared to the 16x2 LCD. Similar to the 16x2, the 20x4 LCD uses the Hitachi controller so the commands and interfaces are the same. It also has the same 16-pin header, allowing you to unplug the 16x2 LCD and plug in the 20x4 without changing any wiring. The only thing we have to change is one line of code,lcd.begin(20, 4), which specifies the columns (first argument) and rows (second argument) of the LCD. An image of the 20x4 LCD is shown below.
There are different types of DHT sensors such as the DHT11, DHT21, DHT22, DHT33, and DHT44. They all measure both temperature and humidity, but the difference lies mostly in their accuracy and sampling rate. For example, we show a side-by-side comparison in the table below of the two most popular DHT sensors, DHT11 and DHT22. The DHT22 has a better accuracy and range, but it has a slower sampling rate, it"s bigger in size, and double the cost of the DHT11.
To measure the temperature and humidity, a thermistor and a capacitive humidity sensor are used, respectively. The resistance of a thermistor changes with a change in temperature - as the temperature increases, the resistance decreases. For the humidity sensor, the resistance between the two electrodes changes with a change in humidity. Both of these changes in resistance are measured by the IC on the sensor and sent to the host via a 1-wire interface. Each sample consists of a 40-bit data packet.
We are using a 3-pin DHT11 sensor as shown in the image below. The pins are "+", "OUT", and "-." The sensor can be supplied with both +5Vdc or +3.3Vdc - we"ll be supplying +5Vdc to it.
We are mounting the DHT11 sensor to the 2.54mm pitch section of Modulus with a right-angle (R/A) female header, as shown in the image below. Solder the 4-pin R/A female header to the edge of the board. Next, solder a 4-pin male header adjacent to the female header. Once you have the headers soldered on, flip the board over and make a solder bridge between the adjacent pins of the headers.
Wire-wrap the "+" pin to +5Vdc which is any of the pins in column 20 on the 4x26-pin breakout. Then wire-wrap the "-" pin to the GND vector just below the 4x26-pin breakout. Use a 12" F/M jumper to connect the "OUT" pin to pin 8 of the Uno. If you are using a breadboard, a wiring schematic is shown below.
If you haven"t mounted the Uno onto the prototyping area of the FuelCan, go ahead and do that. If you are using a breadboard instead of Modulus, place the breadboard in the bottom storage compartment to limit the length of the jumper wires. You"ll need to supply +5V and GND to the power and ground rails on the breadboard by using the provided banana jack to test-lead clip cables. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno"s receptacle. Power up the FuelCan with the AC-DC power adapter.
Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. The first sketch is used with the 16x2 LCD. The second sketch is used with the 20x4 LCD. The DHT11 sensor is sampled every two seconds since sampling faster causes errors.
In this session we will create a device that can measure the temperature and humidity in the environment and display the results in real time on a LCD screen.
Put libraries “dht11” and “LiquidCrystal_I2C” into Arduino IDE’s libraries folder. If you don’t know how to load libraries, please refer to Experiment 12 for details.
2.”break” is used to exit the switch structure. It is usually used in every case. If there is no break, the execution will continue to the next case until it sees break or the switch ends.
Once you are familiar with Arduino, you can even add network module to your controller to allow you to post the real-time data collected to an online platform like weibo or twitter.
This article is a guide for the popular DHT11 and DHT22 temperature and humidity sensors with the Arduino. We’ll explain how it works, show some of its features and share an Arduino project example that you can modify to use in your own projects.
These sensors contain a chip that does analog to digital conversion and spit out a digital signal with the temperature and humidity. This makes them very easy to use with any microcontroller.
The DHT11 and DHT22 are very similar, but differ in their specifications. The following table compares some of the most important specifications of the DHT11 and DHT22 temperature and humidity sensors. For a more in-depth analysis of these sensors, please check the sensors’ datasheet.
The DHT22 sensor has a better resolution and a wider temperature and humidity measurement range. However, it is a bit more expensive, and you can only request readings with 2 seconds interval.
Despite their differences, they work in a similar way, and you can use the same code to read temperature and humidity. You just need to select in the code the sensor type you’re using.
DHT sensors have four pins as shown in the following figure. However, if you get your DHT sensor in a breakout board, it comes with only three pins and with an internal pull-up resistor on pin 2.
Note: if you’re using a module with a DHT sensor, it normally comes with only three pins. The pins should be labeled so that you know how to wire them. Additionally, many of these modules already come with an internal pull up resistor, so you don’t need to add one to the circuit.
To read from the DHT sensor, we’ll use the DHT library from Adafruit. To use this library you also need to install the Adafruit Unified Sensor library. Follow the next steps to install those libraries.
After installing the DHT library from Adafruit, type “Adafruit Unified Sensor” in the search box. Scroll all the way down to find the library and install it.
In the loop(), at the beginning, there’s a delay of 2 seconds. This delay is needed to give enough time for the sensor to take readings. The maximum sampling rate is two seconds for the DHT22 and one second for the DHT11.
Reading temperature and humidity is very simple. To get humidity, you just need to use the readHumidity() method on the dht object. In this case, we’re saving the humidity in the h variable. Note that the readHumidity() method returns a value of type float.
After uploading the code to the Arduino, open the Serial Monitor at a baud rate of 9600. You should get sensor readings every two seconds. Here’s what you should see in your Arduino IDE Serial Monitor.
If you’re trying to read the temperature and humidity from the DHT11/DHT22 sensor and you get an error message in your Serial Monitor, follow the next steps to see if you can make your sensor work (or read our dedicated DHT Troubleshooting Guide).
Wiring: when you’re building an electronics project, you need to double-check the wiring or pin assignment. After checking and testing that your circuit is properly connected, if it still doesn’t work, continue reading the next troubleshooting tips.
Power: the DHT sensor has an operating range of 3V to 5.5V (DHT11) or 3V to 6V (DHT22). If you’re powering the sensor from the a 3.3V pin, in some cases powering the DHT with 5V solves the problem.
Bad USB port or USB cable: sometimes powering the Arduino directly from a PC USB port is not enough. Try to plug it to a USB hub powered by an external power source. It might also help replacing the USB cable with a better or shorter one. Having a USB port that supplies enough power or using a good USB cable often fixes this problem.
Power source: as mentioned in the previous tip, your Arduino might not be supplying enough power to properly read from the DHT sensor. In some cases, you might need to power the Arduino with a power source that provides more current.
Sampling rate: the DHT sensor is very slow getting the readings (the sensor readings may take up to 2 seconds). In some cases, increasing the time between readings solves the problem.
DHT sensor is fried or broken: unfortunately, these cheap sensors sometimes look totally fine, but they are fried/broken. So, even though you assembled the right circuit and code, it will still fail to get the readings. Try to use a different sensor to see if it fixes your problem.
Wrong baud rate or failed to upload code: if you don’t see anything in your Arduino IDE Serial Monitor double-check that you’ve selected the right baud rate, COM port or that you’ve uploaded the code successfully.
While building our projects, we’ve experienced similar issues with the DHT and it was always solved by following one of the methods described earlier.
You need to install the Adafruit Unified Sensor driver library. In your Arduino IDE, type in the search box “Adafruit Unified Sensor“, scroll all the way down to find the library and install it.
The DHT11 and DHT22 sensors provide an easy and inexpensive way to get temperature and humidity measurements with the Arduino. The wiring is very simple – you just need to connect the DHT data pin to an Arduino digital pin.
Writing the code to get temperature and humidity is also simple thanks to the DHT library. Getting temperature and humidity readings is as simple as using the readTemperature() and readHumidity() methods.
This tutorial shows how to use the DHT11 and DHT22 temperature and humidity sensors with the ESP32 using Arduino IDE. We’ll go through a quick introduction to these sensors, pinout, wiring diagram, and finally the Arduino sketch.
These sensors contain a chip that does analog to digital conversion and spit out a digital signal with the temperature and humidity. This makes them very easy to use with any microcontroller.
The DHT11 and DHT22 are very similar, but differ in their specifications. The following table compares some of the most important specifications of the DHT11 and DHT22 temperature and humidity sensors. For a more in-depth analysis of these sensors, please check the sensors’ datasheet.
The DHT22 sensor has a better resolution and a wider temperature and humidity measurement range. However, it is a bit more expensive, and you can only request readings with 2 seconds interval.
Despite their differences, they work in a similar way, and you can use the same code to read temperature and humidity. You just need to select in the code the sensor type you’re using.
DHT sensors have four pins as shown in the following figure. However, if you get your DHT sensor in a breakout board, it comes with only three pins and with an internal pull-up resistor on pin 2.
To read from the DHT sensor, we’ll use the DHT library from Adafruit. To use this library you also need to install the Adafruit Unified Sensor library. Follow the next steps to install those libraries.
After installing the DHT library from Adafruit, type “Adafruit Unified Sensor” in the search box. Scroll all the way down to find the library and install it.
To read temperature and humidity from the DHT sensor, we’ll use an example based on the Adafruit DHT library. Copy the following code to your Arduino IDE.
There are many comments throughout the code with useful information. So, you might want to take a look at the comments. Continue reading to learn how the code works.
Then, you need to select the DHT sensor type you’re using. The library supports DHT11, DHT22, and DHT21. Uncomment the sensor type you’re using and comment all the others. In this case, we’re using the DHT22 sensor.
The temperature and humidity are returned in float format. We create float variables h, t, and f to save the humidity, temperature in Celsius and temperature in Fahrenheit, respectively.
After getting the humidity and temperature, the library has a method that computes the heat index. You can get the heat index both in Celsius and Fahrenheit as shown below:
After uploading the code, open the Serial Monitor at a baud rate of 9600. You should get the latest temperature and humidity readings in the Serial Monitor every two seconds.
If you’re trying to read the temperature and humidity from the DHT11/DHT22 sensor and you get an error message in your Serial Monitor, follow the next steps to see if you can make your sensor work (or read our dedicated DHT Troubleshooting Guide).
Wiring: when you’re building an electronics project, you need to double-check the wiring or pin assignment. After checking and testing that your circuit is properly connected, if it still doesn’t work, continue reading the next troubleshooting tips.
Power: the DHT sensor has an operating range of 3V to 5.5V (DHT11) or 3V to 6V (DHT22). If you’re powering the sensor from the ESP32 3.3V pin, in some cases powering the DHT with 5V solves the problem.
Bad USB port or USB cable: sometimes powering the ESP32 directly from a PC USB port is not enough. Try to plug it to a USB hub powered by an external power source. It might also help replacing the USB cable with a better or shorter one. Having a USB port that supplies enough power or using a good USB cable often fixes this problem.
Power source: as mentioned in the previous tip, your ESP might not be supplying enough power to properly read from the DHT sensor. In some cases, you might need to power the ESP with a power source that provides more current.
Sampling rate: the DHT sensor is very slow getting the readings (the sensor readings may take up to 2 seconds). In some cases, increasing the time between readings solves the problem.
DHT sensor is fried or broken: unfortunately, these cheap sensors sometimes look totally fine, but they are fried/broken. So, even though you assembled the right circuit and code, it will still fail to get the readings. Try to use a different sensor to see if it fixes your problem.
Wrong baud rate or failed to upload code: if you don’t see anything in your Arduino IDE Serial Monitor double-check that you’ve selected the right baud rate, COM port or that you’ve uploaded the code successfully.
While building our projects, we’ve experienced similar issues with the DHT and it was always solved by following one of the methods described earlier.
You need to install the Adafruit Unified Sensor driver library. In your Arduino IDE, type in the search box “Adafruit Unified Sensor“, scroll all the way down to find the library and install it.
With this tutorial you’ve learned how to get temperature and humidity readings from a DHT11 or DHT22 sensor using the ESP32 with Arduino IDE. Getting temperature and humidity readings with the Adafruit DHT library is very simple, you just use the readTemperature() and readHumidity() methods on a DHT object.
Now, you can take this project to the next level and display your sensor readings in a web server that you can consult using your smartphone’s browser. Learn how to build a web server with the ESP32 to display your sensor readings: ESP32 DHT11/DHT22 Web Server – Temperature and Humidity using Arduino IDE.
Arduino DHT11 sensor tutorial that shows how to measure temperature and humidity with an Arduino Uno and Arduino MEGA 2560. The DHT11 four pin sensor measures air temperature and relative humidity. This tutorial shows how to connect a DHT11 temperature and humidity sensor to an Arduino Uno and MEGA 2560. Build a breadboard circuit using the DHT11 sensor and connect it to an Arduino. After that, install a DHT11 library in the Arduino IDE. Finally use the library in a sketch to read and display temperature and humidity. Display temperature and humidity in the serial monitor window of the Arduino IDE.
The following image shows the DHT11 sensor pin numbering or pinout. As can be seen in the image, the sensor has a blue plastic case with square holes. Because of the holes, air passes onto the sensor surface. This allows the sensor to measure the current air temperature and relative humidity.
Power the DHT11 sensor with 5V from the Arduino, as explained in the next section. This sensor clocks temperature and humidity data out of the DATA pin. That is, it sends serial digital data out on the pin, rather than outputting an analog value. This is different from the MCP9700 temperature sensor that outputs an analog voltage that represents temperature. In order to use the DHT11 sensor in an Arduino sketch, a DHT11 library is loaded in the Arduino IDE. The section after the circuit diagram that follows explains how to install a DHT11 sensor library.
The following circuit diagram shows how to connect a DHT11 sensor to an Arduino Uno. Use the same connections on an Arduino MEGA 2560. That is, connect the DHT11 VDD or VCC pin to Arduino 5V. After that, connect the DHT11 GND pin to Arduino GND. Finally connect the DATA or IO pin of the DHT11 to an Arduino digital pin. Use Arduino digital pin 2 in this tutorial, as show in the circuit diagram.
In the circuit diagram, capacitor C1 is an optional capacitor. It is intended to be placed close to the sensor power pins to help stabilize the supply voltage. Resistor R1 is a 4k7 pull-up resistor. In fact a value of between 4k7 and 10k works fine for R1. Breadboard layout circuits follow in two subsections for the Uno and MEGA 2560.
Some tutorials connect the DATA pin of the DHT11 sensor to an Arduino analog pin such as A0. This only works because analog pins can actually be used as digital pins. That is because they are multi-function pins. Refer to the Ultimate Arduino Uno Hardware Manual for the Arduino Uno to find out how analog pins are configured as digital input/output pins, as well as analog input pins. Find the same information in the Ultimate Arduino MEGA 2560 Hardware Manual for the Arduino MEGA 2560.
Notice that the DHT11 symbol pin labels in the circuit diagram differ from the labels on the sensor at the right of the circuit. On the sensor, pin 1 is VDD, pin 2 is DATA, and pin 4 is GND. These names are from the translated DHT11 datasheet. The n.c. pin is a not connected pin that does nothing. In contrast, the symbol for the DHT11 sensor has the following different labels. Firstly pin 1 which is VDD is labeled VCC instead. Secondly pin 2 which is DATA is labeled IO on the symbol. Just be aware of these different labels, and know that they are alternate names for the same pins.
A 4k7 resistor is a 4700 ohm resistor. Similarly it can be called a 4.7k resistor. When written as 4k7, the k separates the thousands units from the hundred units of the value. In other words, it separates 4, which is 4000 ohms from 7, which is 700 ohms.
A 5% tolerance 4k7 resistor has the color bands yellow, violet and red. After that is the gold 5% tolerance band. Yellow has the value 4, violet 7 and red 2. Place the values from the first two color bands to together. That is 4 and 7 which gives 47. Finally place the number of zeros represented by the third color band after the first two digits. That is 2 in this example, which is two zeros. Finally we have 4700, which is written 4k7 for short. Refer back to resistors for beginners in electronics if needed. That article has the resistor color chart at the bottom of the page.
Build the circuit from above on a breadboard and connect it to an Arduino Uno as shown below. Optional capacitor C1 shown in the circuit diagram is not placed in the breadboard circuit. If you have an Arduino MEGA 2560, then build the breadboard circuit shown in the next subsection.
Build the following DHT11 breadboard circuit if you have an Arduino MEGA 2560. Optional capacitor C1 shown in the circuit diagram is not used in the breadboard circuit. Feel free to take 5V and GND from the connector at the end of the Arduino MEGA 2560 if desired. The following breadboard layout makes the connections clear. It avoids crossing wires. Build the circuit how you like, so long as it is electrically the same as the circuit diagram.
Currently there is no default DHT11 library in the Arduino IDE. Install a library in the Arduino IDE in the next section. After that, load a sketch to the Arduino that gets the temperature and humidity from the DHT11.
Open the Arduino IDE. After that, select Tools → Manage Libraries… from the top IDE menu bar. As a result, the Library Manager dialog box opens. Type DHT11 in the top right search box of the Library Manager dialog box. This filters available libraries that apply to the DHT11 sensor as shown in the following image. Hover the mouse cursor over the DHT sensor library, as the below image shows. As a result an Install button appears. Click the Install button to install the DHT sensor library.
A dependencies dialog box opens after clicking the Install button in the Library Manager. This is because the DHT sensor library relies on another library in order to work. Click the Install all button in the dependencies dialog box to install the extra library. A red dot highlights the button in the following image.
Click the Close button at the bottom right of the Library Manager dialog box after the library installation has finished. Run sketch code in the next section that gets the temperature and humidity from the DHT11 sensor.
An example sketch called DHTtester was installed with the DHT sensor library. Open this example sketch as follows. Select File → Examples → DHT sensor library → DHTtester from the top Arduino IDE menu bar. The DHT sensor library item is far down the Examples menu. With the mouse cursor on the menu that pops out from Examples, scroll down the menu. Eventually a heading appears called Examples from Custom Libraries. Find the DHT sensor library menu item under this heading. Finally, click the DHTtester item on this menu.
Comment out the DHT22 item and uncomment the DHT11 item. Afterwards, the code looks as follows. This selects the DHT11 sensor to read from in the sketch.
Save the sketch. As in a previous part of this tutorial series, the example sketch is write only. Save it to your Arduino sketch folder. For example save it as DHTtester_DHT11. Finally upload the sketch to the target Arduino board with the DHT11 circuit connected.
Open the Arduino IDE serial monitor window. Make sure that the baud rate at the bottom of the serial monitor window is set to 9600 baud. The serial monitor window displays the current humidity and temperature. New humidity and temperature values appear in serial monitor window approximately every two seconds. The following image shows the humidity and temperature readings in the serial monitor window.
Breath on the sensor and the humidity reading goes up, assuming the relative humidity is not already very high. Touch the sensor with your fingers and the humidity and temperature readings go up. Response time of the DHT11 sensor is fairly slow. It takes a few seconds for readings to stabilize.
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.
In this tutorial, you will learn how DHT11 and DHT22/AM2302 digital temperature and humidity sensors work and how you can use them with Arduino. These sensors are very popular for DIY electronics projects and are perfect for remote weather stations, home automation projects, and plant/garden monitoring systems.
In this article, I have included wiring diagrams and several example codes so you can start experimenting with your sensor. After each example, I break down and explain how the code works, so you should have no problems modifying it to suit your needs.
First, we will take a look at the Adafruit DHT library. Next, I will show you how you can combine the sensor with a 16×2 LCD to create a simple weather station.
Makerguides.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to products on Amazon.com.
If you open up a DHT11 or DHT22/AM2302 sensor, you will see that it contains two sensing elements: a humidity sensing element and an NTC (thermistor).
On the back of the sensor, you will find a small IC that measures and processes the analog signal. It also stores the calibration coefficients and does the analog to digital conversion.
When you look at the datasheet of the DHTxx sensors, you will see that they measure the relative humidity (RH) of the air and not the absolute humidity. But what’s the difference? The absolute humidity is the amount of water vapor in the air (expressed in g/m³), regardless of temperature. The relative humidity does take temperature into account.
Relative humidity is the ratio between the actual amount of water vapor present in the air and the maximum amount of water vapor that the air can hold at a given temperature.
Warm air can hold more water than cold air. This means that for the same amount of water vapor in the air, the relative humidity in cool air will be higher than that in warm air. At 100 percent relative humidity, the air is saturated and is at its dewpoint.
As you can see, the specifications of the DHT11 and the DHT22/AM2302 are quite similar. The main difference is that the DHT22 is more accurate and has a larger measuring range.
The nice thing about these sensors is that they are interchangeable, meaning that you can just replace the DHT11 with a DHT22 or vice versa, the wiring is exactly the same. You will only have to make a small change in the code setup, as you will see later.
The wiring diagrams/schematics below show you how to connect 3 or 4 pin temperature and humidity sensors to the Arduino Uno. A 10 kΩ pull-up resistor is needed between the signal line and 5 V to make sure the signal level stays high by default (see the datasheet for more info).
Note that the DHT22/AM2302 sensor is connected in the exact same way as the DHT11. The connections are also given in the table below. I numbered the pins 1 to 4 from left to right when the holes in the sensor are facing towards you.
You can also buy the sensors mounted on a small PCB (3 pin sensors). These breakout boards make it easier to connect the sensor to the Arduino and also already include a pull-up resistor. Be sure to check the label of the sensor, the order of the pins can be different depending on the manufacturer.
Another option is to navigate to Tools > Manage Libraries… or type Ctrl + Shift + I on Windows. The Library Manager will open and update the list of installed libraries.
Next, we need to define the DHT to Arduino connection pin and also set the DHT sensor type. In our example, we are using a DHT11 sensor connected to pin 2.
The statement #define is used to give a name to a constant value. The compiler will replace any references to this constant with the defined value when the program is compiled. So everywhere you mention DHTPIN, the compiler will replace it with the value 2 when the program is compiled.
In this case, I called the sensor ‘dht’ but you can use other names as well, like ‘temperature_sensor’ or ‘dht11’ etc. DHT temperature_sensor = DHT(DHTPIN, DHTTYPE);. You can create multiple instances of the DHT class with different names and pins/types. This allows you to easily use 2 or more sensors at the same time.
In the setup(), we start serial communication at a baud rate of 9600. Make sure that the Serial Monitor is also set to 9600! We also initialize the sensor with dht.begin().
The loop() section of the code starts with a delay of 2 seconds. This delay is there to give the sensor some time to do the readings. The maximum sensing rate of the DHT22 is every 2 seconds and that of the DHT11 is once every second.
Taking temperature and humidity readings is super easy because the library has several functions built-in. To get a humidity reading in ‘%’, you can use the function readHumidity(). In this case, we are saving the reading as the ‘h’ variable. Note that it is of the type float.
If you want to get the temperature in Fahrenheit instead of Celsius, you have two options. You can pass true to the readTemperature function, or you can use the convert function:
Next, there is a small section of code that checks if the sensor is connected correctly and is returning a reading. If not, an error message will be printed on the Serial Monitor.
The library also has a function built-in that can compute the heat index by combining the temperature and humidity readings. The heat index is also known as the “felt air temperature” or “apparent temperature”.
In the following example, I will be using an I2C character LCD like this one from Amazon. You can read more about using an I2C LCD with Arduino in the article below:
You will need to make some extra connections to the Arduino so we can control the 16×2 character LCD. The DHT11 or DHT22/AM2302 sensor is connected in the same way as before.
If you are not using an Arduino Uno, the SDA and SCL pins can be at a different location. An Arduino UNO with the R3 layout (1.0 pinout), also has the SDA (data line) and SCL (clock line) pin headers close to the AREF pin. Check the table below for more details.
The code uses the LiquidCrystal_I2C library, which you can download here on GitHub. It also includes the Wire.h library, which allows you to communicate with I2C devices. This library should come pre-installed with the Arduino IDE.
Power:Although the DHTxx sensors can work from 3.3 to 5 V, the manufacturer recommends 5 V. In some cases, powering the sensor with 5 V solves the problem. Make sure that yo