Simple test

Ensure your device works with this simple test.

examples/htu21d_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5import board
 6from adafruit_htu21d import HTU21D
 7
 8# Create sensor object, communicating over the board's default I2C bus
 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
11sensor = HTU21D(i2c)
12
13
14while True:
15    print("\nTemperature: %0.1f C" % sensor.temperature)
16    print("Humidity: %0.1f %%" % sensor.relative_humidity)
17    time.sleep(2)