AHT10 High Precision I2C Digital Temp+Humidity Sensor Module Example Code
AHT10 High Precision I²C Temperature & Humidity Sensor Module Guide
The AHT10 High Precision I²C Digital Temperature and Humidity Sensor Module is a compact sensor used to measure ambient temperature and relative humidity in Arduino, ESP32, Raspberry Pi, weather station, greenhouse, smart home, and STEM electronics projects.
Using the I²C communication interface, the AHT10 only requires two data lines, making it easy to connect while still providing accurate digital readings. It is a great choice for projects that need reliable environmental monitoring without complex wiring.
Required Arduino Library
For Arduino projects, install an AHT10 or Adafruit AHTX0 compatible library using the Arduino Library Manager.
Arduino Example Code
#include <Wire.h>
#include <Adafruit_AHTX0.h>
Adafruit_AHTX0 aht;
void setup() {
Serial.begin(9600);
if (!aht.begin()) {
Serial.println("Could not find AHT10 sensor");
while (1);
}
Serial.println("AHT10 sensor found");
}
void loop() {
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity.relative_humidity);
Serial.println(" %");
delay(2000);
}
Typical Wiring
AHT10 VIN/VCC -> Arduino 3.3V or 5V
AHT10 GND -> Arduino GND
AHT10 SDA -> Arduino SDA
AHT10 SCL -> Arduino SCL
Common Applications
- Weather station projects
- Greenhouse monitoring
- Smart home climate sensing
- Terrarium and enclosure monitoring
- Data logging projects
- Arduino and STEM education projects
Usage Tips
For best results, place the sensor where air can circulate freely around it. Avoid mounting it directly beside heat-producing components, voltage regulators, power supplies, or enclosed electronics that may affect the temperature reading.
If using the sensor outdoors or in damp environments, protect the module from direct water exposure while still allowing airflow for accurate humidity readings.
Arduino Modules & Sensors
Battery Compartments
Component Cases
Electronics Kits
Microcontroller Boards
Project Enclosures
Shields & Hats
Tablets
Laptops
Laptop Accessories
CPU (Processor)
CPU Coolers
GPU (Graphics)
HDD/ SSD (Storage)
MOBO (Motherboard)
PSU (Power Supply)
RAM (Memory)
Keyboard & Mouse Combo
Keyboards
Printers
USB