DHT21/AM2301 Temperature and Humidity Sensor Features
The AM2301 / DHT21 temperature and humidity sensor consists of two sensors: A capacitive humidity sensor and a thermistor. This sensor transmits data using a single digital pin, so it can communicate with the microcontroller using only one digital pin. The sampling frequency is 0.5Hz, which means that you can get new data every two seconds.
DHT21/AM2301 Temperature and Humidity Sensor Pinout
This Module has 3 wires:
- VCC (Red): Module power supply – 5V
- GND (Black): Ground
- DATA (Yellow): Data pin
You can see the pinout of this module in the image below.
Interfacing DHT21/AM2301 Temperature and Humidity Sensor with Arduino
Step 1: Circuit
The following circuit show how you should connect Arduino to DHT21 sensor. Connect wires accordingly.
Step 2: Library
Then go to the Include Library and install DHT sensor library.
Step 3: Code
Upload the following code to Arduino. After that, open the Serial Monitor.
/* modified on Dec 29, 2020 Modified by MehranMaleki from Arduino Examples
In this code, the humidity and temperature data are received from the sensor every 2 seconds and displayed on the Serial Monitor.
The output is as follows: