Simple test

Ensure your device works with this simple test.

examples/scd4x_simpletest.py
 1# SPDX-FileCopyrightText: 2020 by Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5import board
 6import adafruit_scd4x
 7
 8i2c = board.I2C()
 9scd4x = adafruit_scd4x.SCD4X(i2c)
10print("Serial number:", [hex(i) for i in scd4x.serial_number])
11
12scd4x.start_periodic_measurement()
13print("Waiting for first measurement....")
14
15while True:
16    if scd4x.data_ready:
17        print("CO2: %d ppm" % scd4x.CO2)
18        print("Temperature: %0.1f *C" % scd4x.temperature)
19        print("Humidity: %0.1f %%" % scd4x.relative_humidity)
20        print()
21    time.sleep(1)