Simple test

Ensure your device works with this simple test.

examples/si7021_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5Initializes the sensor, gets and prints readings every two seconds.
 6"""
 7import time
 8import board
 9import adafruit_si7021
10
11# Create library object using our Bus I2C port
12i2c = board.I2C()  # uses board.SCL and board.SDA
13# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
14sensor = adafruit_si7021.SI7021(i2c)
15
16# If you'd like to use the heater, you can uncomment the code below
17# and pick a heater level that works for your purposes
18#
19# sensor.heater_enable = True
20# sensor.heater_level = 0  # Use any level from 0 to 15 inclusive
21
22while True:
23    print("\nTemperature: %0.1f C" % sensor.temperature)
24    print("Humidity: %0.1f %%" % sensor.relative_humidity)
25    time.sleep(2)