Monitor temperature and humidity using DHT11 🌡️
Monitoring temperature and humidity is important in many applications, including medical equipment and air conditioning systems.
In this simple tutorial, we will use the Arduino to print the temperature and humidity values on your computer using a suitable sensor called the DHT11.
Overview
The DHT11 is an amazing sensor that allows you to measure temperature in Celsius or Fahrenheit degrees and humidity in % using Arduino.
It is simple and straightforward to use with the appropriate Arduino libraries. It provides a calibrated output so you can display the values and use them directly in various projects and applications.
Let’s find out more together!

Getting the items
For this project you will need the following components you can buy them from our store.
Wiring it up
To set up the DHT11 sensor in the correct way, follow the instructions below. The image demonstrates how to connect the wires between the DHT11 sensor and the Arduino. Once the DHT11 sensor and the Arduino are connected to each other, connect the Arduino to your computer using the USB cable.

Connections from the Arduino to the DHT11:
• Arduino GND pin → DHT11 GND pin (- pin)
• Arduino 5V pin → DHT11 VCC pin (+ pin)
• Arduino pin 3 → DHT11 out pin
Coding
The function of this sketch is to obtain the temperature values in Celsius degrees as well as the humidity of the air in percentage from the DHT11 sensor and display them on your computer.
In order for the code to work correctly, you need to download the sensor library.
Libraries are files that you can download and copy to the Arduino IDE software files so the Arduino can recognize different sensors. You can download the library files from the resources section and then install it by following this tutorial.
/*
Voltaat learn (https://www.voltaat.com/pages/voltaat-learn)
Link for full tutorial: https://bit.ly/3ssbaBr
Link for libraries: https://bit.ly/3FeXMYL
Tutorial: Monitor temperature and humidity using DHT11
This is an Arduino sketch that monitor temperature in Celsius degrees and humidity
in percentage by using the DHT11 sensor with Arduino
Connections from the Arduino to the DHT11:
• Arduino GND pin → DHT11 GND pin (- pin)
• Arduino 5V pin → DHT11 VCC pin (+ pin)
• Arduino pin 3 → DHT11 out pin
*/
//include the DHT sensor Library
#include < DHT.h >
//Define Parameters to DHT function, 3 Refers to digital pin 3 in arduino which you can change with any other digital pin, DHT11 is the sensor type.
DHT dht(3, DHT11);
//define two variables for Temperature and Humidity.
float Temperature, Humidity;
// Commands inside void setup run once.
void setup()
{
//Initialize the DHT sensor with the begin() method.
dht.begin();
//Start the serial monitor at 9600 baud rate (9600 bits per second)
Serial.begin(9600);
}
//Commands inside void loop run forever
void loop()
{
//wait for 1 sec to get a stable reading from the sensor
delay(1000);
//Read the Temperature value from the sensor
//You can use Temperature = dht.readTemperature(True); to print the temperature value in Fahrenheit.
Temperature = dht.readTemperature();
//Read the Humidity value from the sensor
Humidity = dht.readHumidity();
//print "The Temperature = " to the serial monitor
Serial.print("The Temperature = ");
//print temperature value at the same line
Serial.print(Temperature);
//print " Celsius" to the serial monitor at the same line
Serial.print(" Celsius");
//print " The Humidity = " to the serial monitor at the same line
Serial.print(" The Humidity = ");
//print The Humidity value to the serial monitor at the same line
Serial.print(Humidity);
//print "%" sign to the serial monitor then add new line
Serial.println("%");
}
Testing it out

Now you must have correctly wired the DHT11 sensor to the Arduino as we explained in the wiring section, as well as uploaded the code to your Arduino board.
You may now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

The serial monitor is a great tool that can facilitate communication between the computer and the Arduino. It allows us to send and receive different commands as well as view information directly from the Arduino.
Now as we see in the following image, the serial monitor displays temperature and humidity values. The value is updated and printed every second because of the delay we made in our code.
You should also make sure you have chosen the right baud rate (9600) as specified in the code.

Related Tutorials
LCDs are used in a range of everyday applications, including the automobile radio and the house air conditioning remote. They display data and let you control it through menus.
A soil moisture sensor is a device that measures the amount of water in the soil. The sensor consists of two metal probes that can be inserted into the soil to measure the moisture levels.
Most of us are familiar with the switches used in household devices. A relay is a type of switch that can be connected to an Arduino or any other microcontroller.