- All products
- Sensors & Modules
- Temp + Humidity
- DHT21 AM2301 Temperature & Humidity Sensor for Arduino
- Temp + Humidity
Features
- Low power consumption
- No external components required
- Calibrated digital output
- Excellent long term stability
- Interchangeable sensor units
- Measures relative humidity and temperature
Principle of Operation
The sensor operates using a single bus communication method where the microcontroller acts as the master. The host initiates communication and the sensor responds with the latest measured values. A minimum interval of two seconds between readings is required to allow the sensor to complete a full measurement cycle.
For cable lengths under thirty meters a pull up resistor value around five kilo ohm is recommended. When powered from three point three volts the cable length should be kept short to avoid voltage drop and measurement errors.
Pinout
- VCC power supply from three point five to five point five volts
- DATA digital output for temperature and humidity
- GND ground connection
Incorrect wiring of power and ground may permanently damage the sensor.
Typical Connections
- Red wire to Arduino three point three volt or five volt
- Black wire to Arduino ground
- Yellow wire to Arduino digital pin two
Applications
- Environmental monitoring systems
- Internet of Things weather monitoring
- Home automation projects
- Industrial temperature and humidity logging
Arduino Library
The DHT library is required to communicate with the DHT21 sensor. It can be installed using the Arduino library manager by adding the library zip file.
Example Arduino Code
#include "dht.h"
dht DHT;
#define DHT21_PIN 2
float humidity;
float temperature;
void setup()
{
Serial.begin(9600);
}
void loop()
{
DHT.read21(DHT21_PIN);
humidity = DHT.humidity;
temperature = DHT.temperature;
Serial.print("Humidity ");
Serial.print(humidity);
Serial.print(" Temperature ");
Serial.print(temperature);
Serial.println(" Celsius");
delay(2000);
}
Technical Specifications
- Model AM2301
- Supply voltage three point three to five point two volts
- Digital signal output
- Temperature range minus forty to plus eighty Celsius
- Temperature accuracy zero point five Celsius
- Humidity range ten to ninety relative humidity
- Humidity accuracy three relative humidity
- Dimensions fifty-nine by twenty seven by thirteen millimeter
Comparison
The DHT21 is an improved alternative to the DHT11 and offers a wider measurement range and better accuracy. Compared to the DHT22 it provides similar performance but may be used either as a bare sensor or as a module. For simple beginner projects where only temperature is required, an analog sensor such as the LM35 may be easier to use.
Features
- Low power consumption
- No external components required
- Calibrated digital output
- Excellent long term stability
- Interchangeable sensor units
- Measures relative humidity and temperature
Principle of Operation
The sensor operates using a single bus communication method where the microcontroller acts as the master. The host initiates communication and the sensor responds with the latest measured values. A minimum interval of two seconds between readings is required to allow the sensor to complete a full measurement cycle.
For cable lengths under thirty meters a pull up resistor value around five kilo ohm is recommended. When powered from three point three volts the cable length should be kept short to avoid voltage drop and measurement errors.
Pinout
- VCC power supply from three point five to five point five volts
- DATA digital output for temperature and humidity
- GND ground connection
Incorrect wiring of power and ground may permanently damage the sensor.
Typical Connections
- Red wire to Arduino three point three volt or five volt
- Black wire to Arduino ground
- Yellow wire to Arduino digital pin two
Applications
- Environmental monitoring systems
- Internet of Things weather monitoring
- Home automation projects
- Industrial temperature and humidity logging
Arduino Library
The DHT library is required to communicate with the DHT21 sensor. It can be installed using the Arduino library manager by adding the library zip file.
Example Arduino Code
#include "dht.h"
dht DHT;
#define DHT21_PIN 2
float humidity;
float temperature;
void setup()
{
Serial.begin(9600);
}
void loop()
{
DHT.read21(DHT21_PIN);
humidity = DHT.humidity;
temperature = DHT.temperature;
Serial.print("Humidity ");
Serial.print(humidity);
Serial.print(" Temperature ");
Serial.print(temperature);
Serial.println(" Celsius");
delay(2000);
}
Technical Specifications
- Model AM2301
- Supply voltage three point three to five point two volts
- Digital signal output
- Temperature range minus forty to plus eighty Celsius
- Temperature accuracy zero point five Celsius
- Humidity range ten to ninety relative humidity
- Humidity accuracy three relative humidity
- Dimensions fifty-nine by twenty seven by thirteen millimeter
Comparison
The DHT21 is an improved alternative to the DHT11 and offers a wider measurement range and better accuracy. Compared to the DHT22 it provides similar performance but may be used either as a bare sensor or as a module. For simple beginner projects where only temperature is required, an analog sensor such as the LM35 may be easier to use.