Simple test

Ensure your device works with this simple test.

examples/sht4x_simpletest.py
 1# SPDX-FileCopyrightText: Copyright (c) 2020 ladyada for Adafruit Industries
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import time
 6import board
 7import adafruit_sht4x
 8
 9i2c = board.I2C()  # uses board.SCL and board.SDA
10# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
11sht = adafruit_sht4x.SHT4x(i2c)
12print("Found SHT4x with serial number", hex(sht.serial_number))
13
14sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION
15# Can also set the mode to enable heater
16# sht.mode = adafruit_sht4x.Mode.LOWHEAT_100MS
17print("Current mode is: ", adafruit_sht4x.Mode.string[sht.mode])
18
19while True:
20    temperature, relative_humidity = sht.measurements
21    print("Temperature: %0.1f C" % temperature)
22    print("Humidity: %0.1f %%" % relative_humidity)
23    print("")
24    time.sleep(1)