CircuitPython driver for the Adafruit AHT10/AHT20 Temperature & Humidity Sensor

  • Author(s): Kattni Rembor

Implementation Notes


Software and Dependencies:

class adafruit_ahtx0.AHTx0(i2c_bus, address=56)

Interface library for AHT10/AHT20 temperature+humidity sensors

  • i2c_bus (I2C) – The I2C bus the AHT10/AHT20 is connected to.
  • address (int) – The I2C device address. Default is 0x38

Quickstart: Importing and using the AHT10/AHT20 temperature sensor

Here is an example of using the AHTx0 class. First you will need to import the libraries to use the sensor

import board
import adafruit_ahtx0

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
aht = adafruit_ahtx0.AHTx0(i2c)

Now you have access to the temperature and humidity using the temperature and relative_humidity attributes

temperature = aht.temperature
relative_humidity = aht.relative_humidity

Ask the sensor to self-calibrate. Returns True on success, False otherwise


The measured relative humidity in percent.


Perform a soft-reset of the AHT


The status byte initially returned from the sensor, see datasheet for details


The measured temperature in degrees Celsius.