Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use AM2302 Humidity and Temperature Sensor: Examples, Pinouts, and Specs

Image of AM2302 Humidity and Temperature SensorDesign with AM2302 Humidity and Temperature Sensor in Cirkit Designer

Introduction

The AM2302 sensor, also known as the DHT22, is a reliable digital sensor that measures both humidity and temperature. It combines a capacitive humidity sensor and a thermistor to provide accurate readings of the surrounding environment. This sensor is widely used in applications such as weather stations, home automation systems, and HVAC monitoring due to its ease of use and precision.

Explore Projects Built with AM2302 Humidity and Temperature Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Wemos D1 Mini Based Soil Moisture and Temperature Monitoring System: A project utilizing AM2302 Humidity and Temperature Sensor in a practical application
Wemos D1 Mini Based Soil Moisture and Temperature Monitoring System

This circuit features a Wemos D1 Mini microcontroller connected to an AHT10 temperature and humidity sensor and a capacitive soil moisture sensor. The AHT10 communicates with the Wemos D1 Mini via I2C (with SDA connected to D2 and SCL to D1), while the soil moisture sensor's analog output is connected to the A0 pin of the Wemos D1 Mini. Both sensors and the microcontroller share a common power supply, with the 3V3 pin of the Wemos D1 Mini providing power to the sensors.

Open Project in Cirkit Designer
Image of Arduino Nano-Based Bluetooth Temperature and Humidity Monitor with OLED Display and Alert Buzzer: A project utilizing AM2302 Humidity and Temperature Sensor in a practical application
Arduino Nano-Based Bluetooth Temperature and Humidity Monitor with OLED Display and Alert Buzzer

This circuit features an Arduino Nano microcontroller interfaced with an AHT10 temperature and humidity sensor, an HC-05 Bluetooth module, a 128x64 OLED display, and a buzzer with a series resistor. The Arduino Nano reads temperature and humidity data from the AHT10 sensor and displays it on the OLED screen. If the temperature exceeds a predefined threshold, the buzzer is activated. The HC-05 Bluetooth module allows for wireless communication, likely to send sensor data to another device such as a smartphone or computer.

Open Project in Cirkit Designer

Technical Specifications

Key Features

Pin Configuration

Pin Number Name Description
1 VDD Power supply (3.3 to 5V DC)
2 DATA Digital output pin
3 NC Not connected
4 GND Ground

Usage Instructions

Connecting to a Circuit

  1. Connect the VDD pin to the 3.3V or 5V output on your microcontroller.
  2. Connect the DATA pin to a digital I/O pin on your microcontroller.
  3. Connect the GND pin to the ground on your microcontroller.
  4. It is recommended to use a 5.1kΩ pull-up resistor between the DATA pin and VDD for reliable communication.

Interfacing with Arduino UNO

To interface the AM2302 with an Arduino UNO, follow these steps:

  1. Connect the sensor as described above, using a digital pin (e.g., pin 2) for the DATA pin.
  2. Download and install the "DHT sensor library" from the Arduino Library Manager.
  3. Use the following example code to read humidity and temperature:
#include "DHT.h"

#define DHTPIN 2     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22   // DHT 22 (AM2302)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  float humidity = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float temperature = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index in Celsius (isFahrenheit = false)
  float heatIndex = dht.computeHeatIndex(temperature, humidity, false);

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print("%  Temperature: ");
  Serial.print(temperature);
  Serial.print("°C  Heat index: ");
  Serial.print(heatIndex);
  Serial.println("°C");
}

Best Practices

Troubleshooting and FAQs

Common Issues

FAQs

Q: How often can I read data from the sensor? A: The AM2302 should not be read more frequently than every 2 seconds to ensure accurate measurements.

Q: Can the sensor be used outdoors? A: Yes, but it should be protected from direct sunlight, rain, and condensation.

Q: Is the sensor waterproof? A: No, the AM2302 is not waterproof and should be protected from water and high humidity that can condense.

For further assistance, consult the datasheet or contact the manufacturer's technical support.