Simple test

Ensure your device works with this simple test.

examples/ahtx0_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5Basic `AHTx0` example test
 6"""
 7
 8import time
 9import board
10import adafruit_ahtx0
11
12# Create sensor object, communicating over the board's default I2C bus
13i2c = board.I2C()  # uses board.SCL and board.SDA
14# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
15sensor = adafruit_ahtx0.AHTx0(i2c)
16
17while True:
18    print("\nTemperature: %0.1f C" % sensor.temperature)
19    print("Humidity: %0.1f %%" % sensor.relative_humidity)
20    time.sleep(2)