Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import board
6import adafruit_hts221
7
8i2c = board.I2C() # uses board.SCL and board.SDA
9# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
10hts = adafruit_hts221.HTS221(i2c)
11
12data_rate = adafruit_hts221.Rate.label[hts.data_rate]
13print("Using data rate of: {:.1f} Hz".format(data_rate))
14print("")
15
16while True:
17 print("Relative Humidity: {:.2f} % rH".format(hts.relative_humidity))
18 print("Temperature: {:.2f} C".format(hts.temperature))
19 print("")
20 time.sleep(1)