Introduction
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 UNO | 1 | Buy Now |
DHT21 / AM2301 Temperature and Humidity Sensor | 1 | Buy Now |
9v DC Adapter (Optional) | 1 | Buy Now |
Jumper Wires | 3 | Buy Now |
Breadboard | 1 | Buy 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.
Pinout
Pin Configuration
Pin Name | Pin Type |
---|---|
VCC (Red) | Power supply – 5V |
GND (Black) | Ground Pin |
DATA (Yellow) | DATA Pin |
Specifications
- Temperature Measurement Range: The DHT21/AM2301 sensor can measure temperatures ranging from -40°C to 80°C, enabling monitoring in extreme environments.
- Humidity Measurement Range: It offers a humidity measurement range of 0% to 100%, providing comprehensive humidity monitoring capabilities.
- Accuracy: The sensor boasts high accuracy levels, ensuring precise temperature and humidity readings for critical applications.
- Interface: The DHT21/AM2301 sensor uses a single-wire digital interface, simplifying its integration with microcontrollers like Arduino UNO.
- Power Supply: The sensor operates within a wide voltage range and requires minimal power, making it energy-efficient and suitable for long-term use.
Features
- Fast Response Time: The DHT21/AM2301 sensor exhibits a fast response time, enabling real-time monitoring and data acquisition.
- Low Cost: The sensor’s affordability makes it accessible to hobbyists, researchers, and professionals alike.
- Compact Size: With its small form factor, the DHT21/AM2301 sensor can be easily integrated into various projects and applications.
- 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
Arduino | Temperature Sensor |
---|---|
+5V | VCC Pin |
GND | GND Pin |
D2 | DATA |
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
Code
//For more Projects: www.arduinocircuit.com
#include <DHT.h>;
//Constants
#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
//Variables
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
}
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(hum);
Serial.print("%, Temperature: ");
Serial.print(temp);
Serial.println(" Celsius");
delay(2000); //Delay 2 sec.
}
Applications
- 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.
- Weather Stations: The DHT21/AM2301 sensor can be integrated into weather stations to measure local temperature and humidity for weather forecasting.
- Greenhouses and Agriculture: The sensor finds applications in greenhouses and agriculture to monitor environmental conditions and optimize plant growth.
- Home Automation: In home automation projects, the sensor can be used to create smart devices that respond to changes in temperature and humidity.
- Environmental Monitoring: The sensor is well-suited for environmental monitoring applications, including air quality assessment and research.
Conclusion
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.