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
10sht = adafruit_sht4x.SHT4x(i2c)
11print("Found SHT4x with serial number", hex(sht.serial_number))
12
13sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION
14# Can also set the mode to enable heater
15# sht.mode = adafruit_sht4x.Mode.LOWHEAT_100MS
16print("Current mode is: ", adafruit_sht4x.Mode.string[sht.mode])
17
18while True:
19    temperature, relative_humidity = sht.measurements
20    print("Temperature: %0.1f C" % temperature)
21    print("Humidity: %0.1f %%" % relative_humidity)
22    print("")
23    time.sleep(1)