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