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: I2C, address: int = 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() bool

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

property relative_humidity: int

The measured relative humidity in percent.

reset() None

Perform a soft-reset of the AHT

property status: int

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

property temperature: int

The measured temperature in degrees Celsius.