AHT20 Temperature & Humidity Sensor and ESP8266 example using the Arduino IDE

In this article we look at a AHT20 Temperature & Humidity Sensor and we will connect it to a Wemos Mini

First lets look at the sensor

AHT20, as a new generation of temperature and humidity sensors, has established a new standard in size and intelligence. It is embedded in a double row flat no-lead package suitable for reflow soldering, with a bottom of 3 x 3 mm and a height of 1.0 mm.

The sensor outputs calibrated digital signals in standard IAHT20, as a new generation of temperature and humidity sensors, has established a new standard in size and intelligence.

It is embedded in a double row flat no-lead package suitable for reflow soldering, with a bottom of 3 x 3 mm and a height of 1.0 mm.

The sensor outputs calibrated digital signals in standard I2C format. AHT20 is equipped with a newly designed ASIC chip, an improved MEMS semiconductor capacitive humidity sensing element and a standard on-chip temperature sensing element.

Supply voltage DC : 2.0 – 5.5V
Measuring range (humidity) 0 ~ 100% RH
Measuring range (temperature) -40 ~ + 85 ℃
Humidity accuracy ± 2 % RH ( 25 ℃ )
Temperature accuracy ± 0.3 ℃
Resolution temperature: 0.01℃ Humidity: 0.024%RH
Response time temperature: 5s humidity: 8s 1/e (63%)
Output signal I2C signal

 

Parts Required

 

Once again for ease of use I connect a Dual Base Shield with a Wemos Mini and then connect the sensor to that as well

Name Link
Wemos Mini WeMos D1 Mini WIFI Development Board
AHT20 AHT20 Temperature and Humidity Sensor Module High-precision Humidity Sensor
Connecting wire Male to Male + Male to Female and Female to Female Jumper Wire Dupont Cable
Dual Base Shield Wemos Dual Base Shield

 

Schematic/Connection

I used the Adafruit TLV493 sensor and in this case used the Stemma connection on the sensor

For the STEMMA QT cables, it uses the Qwiic convention:

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

ESP8266 and AHT20 layout
ESP8266 and AHT20 layout

Code Example

This uses the library from Adafruit installed using the Library Manager in the Arduino IDE. search for AHTx0 , and select the Adafruit AHTx0 Library library and also the Adafruit BusIO library

This is the default example

#include <Adafruit_AHTX0.h>
 
Adafruit_AHTX0 aht;
 
void setup() 
{
  Serial.begin(115200);
  Serial.println("Adafruit AHT10/AHT20 demo!");
 
  if (! aht.begin()) 
  {
    Serial.println("Could not find AHT? Check wiring");
    while (1) delay(10);
  }
  Serial.println("AHT10 or AHT20 found");
}
 
void loop() 
{
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  Serial.print("Temperature: "); 
  Serial.print(temp.temperature); 
  Serial.println(" degrees C");
  Serial.print("Humidity: "); 
  Serial.print(humidity.relative_humidity); 
  Serial.println("% rH");
 
  delay(500);
}

Output

Open the serial monitor and you should see something like this.

Temperature: 22.81 degrees C
Humidity: 52.19% rH
Temperature: 24.23 degrees C
Humidity: 53.64% rH
Temperature: 24.31 degrees C
Humidity: 52.84% rH
Temperature: 24.00 degrees C
Humidity: 51.91% rH

Links

Product download pdf

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*