Interfacing DHT21 / AM2301 Temperature and Humidity Sensor with Arduino


In this tutorial, we are Interfacing DHT21 / AM2301 Temperature and Humidity Sensor with Arduino, The DHT21/AM2301 Temperature and Humidity Sensor offers an efficient and accurate solution for measuring environmental conditions. In this practical guide, we will delve into the working principle and features of the DHT21/AM2301 sensor. Additionally, we will learn how to interface it with an Arduino UNO to create a temperature and humidity monitoring system. By the end of this tutorial, you will possess the knowledge and skills to integrate this sensor into your projects, making informed decisions based on real-time temperature and humidity data. So, let’s embark on this journey of exploring the world of environmental sensing with the DHT21/AM2301 Sensor!

Hardware Required

You will require the following Hardware Components for the Interfacing DHT21 / AM2301 Temperature and Humidity Sensor with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Now
DHT21 / AM2301 Temperature and Humidity Sensor1Buy Now
9v DC Adapter (Optional)1Buy Now
Jumper Wires3Buy Now
Breadboard1Buy Now

What is DHT21 Temperature Sensor?

The DHT21/AM2301 is a digital sensor that combines a temperature sensor and a humidity sensor in a single package. It utilizes a capacitive humidity sensor and a thermistor-based temperature sensor to measure humidity and temperature, respectively. The sensor provides accurate and reliable readings with minimal power consumption, making it suitable for battery-powered applications. With its high-performance capabilities and user-friendly interface, the DHT21/AM2301 sensor is a popular choice for environmental monitoring in both residential and industrial settings.



Pin Configuration

Pin NamePin Type
VCC (Red)Power supply – 5V
GND (Black)Ground Pin
DATA (Yellow)DATA Pin


  1. Temperature Measurement Range: The DHT21/AM2301 sensor can measure temperatures ranging from -40°C to 80°C, enabling monitoring in extreme environments.
  2. Humidity Measurement Range: It offers a humidity measurement range of 0% to 100%, providing comprehensive humidity monitoring capabilities.
  3. Accuracy: The sensor boasts high accuracy levels, ensuring precise temperature and humidity readings for critical applications.
  4. Interface: The DHT21/AM2301 sensor uses a single-wire digital interface, simplifying its integration with microcontrollers like Arduino UNO.
  5. Power Supply: The sensor operates within a wide voltage range and requires minimal power, making it energy-efficient and suitable for long-term use.


  1. Fast Response Time: The DHT21/AM2301 sensor exhibits a fast response time, enabling real-time monitoring and data acquisition.
  2. Low Cost: The sensor’s affordability makes it accessible to hobbyists, researchers, and professionals alike.
  3. Compact Size: With its small form factor, the DHT21/AM2301 sensor can be easily integrated into various projects and applications.
  4. Stable Performance: The sensor’s stable performance ensures consistent and reliable measurements over time.

Circuit Diagram

The following circuit shows you the connection of the Interfacing DHT21 / AM2301 Temperature and Humidity Sensor with Arduino Please make the connection carefully


Circuit Connections

ArduinoTemperature Sensor
+5VVCC Pin

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Installing Libraries

Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow


//For more Projects:

#include <DHT.h>;

#define DHTPIN 2            //what pin we're connected to
#define DHTTYPE DHT21       //DHT 21  (AM2301)
DHT dht(DHTPIN, DHTTYPE);   //Initialize DHT sensor for normal 16mhz Arduino

float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()

void loop()
  //Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp= dht.readTemperature();
  //Print temp and humidity values to serial monitor
  Serial.print("Humidity: ");
  Serial.print("%,  Temperature: ");
  Serial.println(" Celsius");
  delay(2000); //Delay 2 sec.


  1. Indoor Climate Control: The sensor is ideal for indoor climate control systems, allowing for adjustments in heating, ventilation, and air conditioning (HVAC) based on temperature and humidity levels.
  2. Weather Stations: The DHT21/AM2301 sensor can be integrated into weather stations to measure local temperature and humidity for weather forecasting.
  3. Greenhouses and Agriculture: The sensor finds applications in greenhouses and agriculture to monitor environmental conditions and optimize plant growth.
  4. Home Automation: In home automation projects, the sensor can be used to create smart devices that respond to changes in temperature and humidity.
  5. Environmental Monitoring: The sensor is well-suited for environmental monitoring applications, including air quality assessment and research.


You have now gained a comprehensive understanding of the DHT21/AM2301 Temperature and Humidity Sensor and its versatile applications. By interfacing the sensor with Arduino UNO, you can create your own temperature and humidity monitoring system for diverse projects. Whether it’s optimizing indoor climate control, enhancing weather forecasting, or improving agriculture practices, the DHT21/AM2301 sensor offers invaluable environmental sensing capabilities.

Leave a Comment