Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use aht20: Examples, Pinouts, and Specs

Image of aht20
Cirkit Designer LogoDesign 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!
Raspberry Pi Pico-Based Temperature and Humidity Monitoring System
Image of rpi pico with aht20: A project utilizing aht20 in a practical application
This circuit connects an Adafruit AHT20 Temperature and Humidity Sensor to a Raspberry Pi Pico microcontroller. The AHT20 sensor communicates with the Raspberry Pi Pico via I2C protocol, using SCL and SDA lines for clock and data respectively. The sensor is powered by the Pico, with connections for VCC and GND to provide the necessary power supply.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Nano and ESP8266 Wi-Fi Controlled Weather Station with LCD Display
Image of Grain Moisture Monitor: A project utilizing aht20 in a practical application
This circuit is a microcontroller-based system that uses an Arduino Nano to read data from an AHT10 temperature and humidity sensor and display it on a 16x2 LCD. It also includes a WiFi module (ESP8266-01) for wireless communication, powered by a step-down module and a buck converter to provide the necessary voltage levels.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Nano-Based Weather Station with Wi-Fi Connectivity and Multiple AHT10 Sensors
Image of PS2_Group 5: A project utilizing aht20 in a practical application
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.
Cirkit Designer LogoOpen Project in Cirkit Designer
Wemos D1 Mini Based Soil Moisture and Temperature Monitoring System
Image of pfe2: A project utilizing aht20 in a practical application
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.
Cirkit Designer LogoOpen Project in Cirkit Designer

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 rpi pico with aht20: A project utilizing aht20 in a practical application
Raspberry Pi Pico-Based Temperature and Humidity Monitoring System
This circuit connects an Adafruit AHT20 Temperature and Humidity Sensor to a Raspberry Pi Pico microcontroller. The AHT20 sensor communicates with the Raspberry Pi Pico via I2C protocol, using SCL and SDA lines for clock and data respectively. The sensor is powered by the Pico, with connections for VCC and GND to provide the necessary power supply.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Grain Moisture Monitor: A project utilizing aht20 in a practical application
Arduino Nano and ESP8266 Wi-Fi Controlled Weather Station with LCD Display
This circuit is a microcontroller-based system that uses an Arduino Nano to read data from an AHT10 temperature and humidity sensor and display it on a 16x2 LCD. It also includes a WiFi module (ESP8266-01) for wireless communication, powered by a step-down module and a buck converter to provide the necessary voltage levels.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of PS2_Group 5: 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.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of pfe2: 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.
Cirkit Designer LogoOpen 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

  • Ensure the sensor is not exposed to direct sunlight or water to maintain accuracy.
  • Avoid placing the sensor near heat sources or in areas with high airflow, as this may affect readings.
  • Allow the sensor to stabilize for a few seconds after power-up before taking measurements.

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.