Driver in MicroPython for AHT2x: humidity and temperature sensors. The driver covers 100% of the sensor's functionality:
Compatible models:
This driver has no dependency
Copy the file aht.py in your project folder.
.. code-block:: micropython
import time, machine
import aht
# Example SCL pin and SDA pin for WEMOS D1 mini Lite
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
sensor = aht.AHT2x(i2c, crc=True)
# To print one of measures:
if sensor.is_ready:
print("Humidity: {:.2f}".format(sensor.humidity))
print("Temperature: {:.2f}".format(sensor.temperature))
Read the code.
Contributions are welcome!