Simple test
Ensure your device works with this simple test.
examples/shtc3_simpletest.py
1# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries
2#
3# SPDX-License-Identifier: MIT
4import time
5
6import board
7
8import adafruit_shtc3
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
12sht = adafruit_shtc3.SHTC3(i2c)
13
14while True:
15 temperature, relative_humidity = sht.measurements
16 print(f"Temperature: {temperature:0.1f} C")
17 print(f"Humidity: {relative_humidity:0.1f} %")
18 print("")
19 time.sleep(1)
DisplayIO Simple test
This is a simple test for boards with built-in display.
examples/shtc3_displayio_simpletest.py
1# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
2# SPDX-FileCopyrightText: 2024 Jose D. Montoya
3#
4# SPDX-License-Identifier: MIT
5import time
6
7import board
8from adafruit_display_text.bitmap_label import Label
9from displayio import Group
10from terminalio import FONT
11
12import adafruit_shtc3
13
14# create a main_group to hold anything we want to show on the display.
15main_group = Group()
16
17i2c = board.I2C() # uses board.SCL and board.SDA
18# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
19sht = adafruit_shtc3.SHTC3(i2c)
20
21# Create a Label to show the readings. If you have a very small
22# display you may need to change to scale=1.
23display_output_label = Label(FONT, text="", scale=1)
24
25# place the label near the top left corner with anchored positioning
26display_output_label.anchor_point = (0, 0)
27display_output_label.anchored_position = (4, 30)
28
29# add the label to the main_group
30main_group.append(display_output_label)
31
32# set the main_group as the root_group of the built-in DISPLAY
33board.DISPLAY.root_group = main_group
34
35# begin main loop
36while True:
37 temperature, relative_humidity = sht.measurements
38 # Update the label.text property to change the text on the display
39 display_output_label.text = (
40 f"Temperature: {temperature:.1f} C Humidity: {relative_humidity:.1f} %"
41 )
42 # wait for a bit
43 time.sleep(1)