0% found this document useful (0 votes)
35 views

How To Use The DHT11 Temperature and Humidity Sensor With An Arduino!

This document provides instructions for using a DHT11 temperature and humidity sensor with an Arduino board. It explains that the DHT11 sensor requires only 3 connections to the Arduino and measures temperature and humidity accurately enough for most projects. It also introduces a library for reading data from the DHT11 sensor that simplifies the code. The code sample shows how to import the library, read the temperature and humidity values, and print them to the serial monitor every 5 seconds.

Uploaded by

franco
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

How To Use The DHT11 Temperature and Humidity Sensor With An Arduino!

This document provides instructions for using a DHT11 temperature and humidity sensor with an Arduino board. It explains that the DHT11 sensor requires only 3 connections to the Arduino and measures temperature and humidity accurately enough for most projects. It also introduces a library for reading data from the DHT11 sensor that simplifies the code. The code sample shows how to import the library, read the temperature and humidity values, and print them to the serial monitor every 5 seconds.

Uploaded by

franco
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

1 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

Brainy-Bits Oct 1, 2020 1 min read

How to use the DHT11 Temperature and Humidity Sensor


with an Arduino!

OVERVIEW

In this tutorial we will learn how to use a DHT (DHT11 version) Temperature and Humidity Sensor.

It’s accurate enough for most projects that need to keep track of humidity and temperature readings.

Again we will be using a Library specifically designed for these sensors that will make our code short and easy
to write.

PARTS USED

DHT-11 Temperature sensor


Amazon usa
Amazon canada

Arduino UNO
Amazon usa
Amazon canada

2 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

Amazon canada

Dupont Wires
Amazon usa
Amazon canada

These are Amazon affiliate links...


They don't cost you anything and it helps me keep the lights on
if you buy something on Amazon. Thank you!

CONNECTIONS

As you can see we only need 3 connections to the sensor, since one of the pin is not used.

The connection are : Voltage, Ground and Signal which can be connected to any Analog Pin on our UNO.

3 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

THE CODE

Since we will be using a Library that is available for this sensor, our code will be very short and simple.

Once you have the library, just go ahead and extract it to the Library folder inside your Arduino IDE software
folder.

#include "dht.h"
#define dht_apin A0 // Analog Pin sensor is connected to

dht DHT;

void setup(){

Serial.begin(9600);
delay(500);//Delay to let system boot
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);//Wait before accessing Sensor

}//end "setup()"

void loop(){
//Start of Program

DHT.read11(dht_apin);

Serial.print("Current humidity = ");


Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");

delay(5000);//Wait 5 seconds before accessing sensor again.

//Fastest should be once every two seconds.

}// end loop()

4 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

TUTORIAL VIDEO

DOWNLOAD

For the Arduino code, just copy and paste the code above in your Arduino IDE software.

You can download the DHT Library we used here:

DHT_Library.zip
Download ZIP • 2KB

5 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

6 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

7 of 8 17/01/2023 15:43
How to use the DHT11 Temperature and Humidity Sensor with an Arduino! https://www.brainy-bits.com/post/how-to-use-the-dht11-temperature-an...

8 of 8 17/01/2023 15:43

You might also like