adafruit_ahtx0

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

  • Author(s): Kattni Rembor

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ahtx0.AHTx0(i2c_bus, address=56)

Interface library for AHT10/AHT20 temperature+humidity sensors

Parameters:
  • 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
calibrate()

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

relative_humidity

The measured relative humidity in percent.

reset()

Perform a soft-reset of the AHT

status

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

temperature

The measured temperature in degrees Celsius.