etno712 / aht

MicroPython driver for AHT sensors (humidity and temperature)
14 stars 1 forks source link
aht20 aht21 crc8 humidity-sensor micropython-driver temperature-sensor

Code style: black

Introduction

Driver in MicroPython for AHT2x: humidity and temperature sensors. The driver covers 100% of the sensor's functionality:

Compatible models:

Dependencies

This driver has no dependency

Install

Copy the file aht.py in your project folder.

Usage Example

.. 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))

Documentation

Read the code.

Contributing

Contributions are welcome!