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

How to Use aht20: Examples, Pinouts, and Specs

Image of aht20Design with aht20 in Cirkit Designer

Introduction

The AHT20, manufactured by DFRobot (Part ID: AHT20), is a digital temperature and humidity sensor designed for precise environmental monitoring. It features a compact design, low power consumption, and I2C communication, making it ideal for integration into a wide range of microcontroller-based projects. The AHT20 is widely used in applications such as weather stations, HVAC systems, IoT devices, and industrial automation.

Explore Projects Built with aht20

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 Arduino Nano-Based Weather Station with Wi-Fi Connectivity and Multiple AHT10 Sensors: A project utilizing aht20 in a practical application
Arduino Nano-Based Weather Station with Wi-Fi Connectivity and Multiple AHT10 Sensors

This circuit features an Arduino Nano microcontroller interfacing with three AHT10 temperature and humidity sensors, an ESP8266-01 WiFi module, and a 16x2 LCD display. It includes power regulation components to step down voltage and manage power distribution, and rocker switches for user input. The setup is designed for environmental monitoring and data display with potential for wireless communication.

Open Project in Cirkit Designer
Image of Wemos D1 Mini Based Soil Moisture and Temperature Monitoring System: A project utilizing aht20 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

Technical Specifications

The AHT20 offers reliable performance with the following key specifications:

Parameter Value
Supply Voltage 2.0V to 5.5V
Operating Current 0.25 mA (average)
Communication Interface I2C
Temperature Range -40°C to 85°C
Temperature Accuracy ±0.3°C
Humidity Range 0% to 100% RH
Humidity Accuracy ±2% RH
Response Time ≤8 seconds
Dimensions 3.8mm x 3.8mm x 1.0mm

Pin Configuration and Descriptions

The AHT20 sensor has four pins, as described in the table below:

Pin Name Description
VCC Power supply input (2.0V to 5.5V)
GND Ground
SDA I2C data line
SCL I2C clock line

Usage Instructions

How to Use the AHT20 in a Circuit

  1. Power Supply: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to ground.
  2. I2C Communication: Connect the SDA and SCL pins to the corresponding I2C pins on your microcontroller. Use pull-up resistors (typically 4.7kΩ) on the SDA and SCL lines if not already present.
  3. Address: The AHT20 has a fixed I2C address of 0x38.

Important Considerations and Best Practices

Example Code for Arduino UNO

Below is an example of how to interface the AHT20 with an Arduino UNO using the I2C protocol:

#include <Wire.h>

// AHT20 I2C address
#define AHT20_ADDRESS 0x38

void setup() {
  Wire.begin(); // Initialize I2C communication
  Serial.begin(9600); // Start serial communication for debugging

  // Initialize the AHT20 sensor
  Wire.beginTransmission(AHT20_ADDRESS);
  Wire.write(0xBE); // Send initialization command
  Wire.endTransmission();
  delay(10); // Allow time for initialization
}

void loop() {
  // Trigger measurement
  Wire.beginTransmission(AHT20_ADDRESS);
  Wire.write(0xAC); // Trigger measurement command
  Wire.write(0x33); // Data byte 1
  Wire.write(0x00); // Data byte 2
  Wire.endTransmission();
  delay(80); // Wait for measurement to complete

  // Read measurement data
  Wire.requestFrom(AHT20_ADDRESS, 6); // Request 6 bytes of data
  if (Wire.available() == 6) {
    uint8_t data[6];
    for (int i = 0; i < 6; i++) {
      data[i] = Wire.read(); // Read each byte
    }

    // Process temperature and humidity data
    uint32_t humidity = ((uint32_t)data[1] << 12) | ((uint32_t)data[2] << 4) |
                        (data[3] >> 4);
    uint32_t temperature = ((uint32_t)(data[3] & 0x0F) << 16) |
                           ((uint32_t)data[4] << 8) | data[5];

    float humidityPercent = (humidity * 100.0) / 1048576.0;
    float temperatureCelsius = (temperature * 200.0 / 1048576.0) - 50.0;

    // Print results to the serial monitor
    Serial.print("Humidity: ");
    Serial.print(humidityPercent);
    Serial.println(" %");
    Serial.print("Temperature: ");
    Serial.print(temperatureCelsius);
    Serial.println(" °C");
  }

  delay(2000); // Wait 2 seconds before the next reading
}

Troubleshooting and FAQs

Common Issues

  1. No Data from the Sensor:

    • Ensure the sensor is properly connected to the I2C pins of the microcontroller.
    • Verify that the pull-up resistors are in place on the SDA and SCL lines.
    • Check the power supply voltage (2.0V to 5.5V).
  2. Inaccurate Readings:

    • Ensure the sensor is not exposed to extreme environmental conditions.
    • Allow the sensor to stabilize after power-up before taking measurements.
  3. I2C Communication Errors:

    • Confirm the I2C address (0x38) matches the one used in your code.
    • Check for loose or incorrect wiring.

FAQs

Q: Can the AHT20 operate at 5V?
A: Yes, the AHT20 supports a supply voltage range of 2.0V to 5.5V, making it compatible with both 3.3V and 5V systems.

Q: How often can I take measurements?
A: The AHT20 has a response time of ≤8 seconds, but it is recommended to wait at least 2 seconds between measurements for optimal performance.

Q: Do I need to calibrate the AHT20?
A: No, the AHT20 is factory-calibrated and does not require additional calibration.