Simple test

Ensure your device works with this simple test.

examples/scd30_simpletest.py
 1# SPDX-FileCopyrightText: 2020 by Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5import board
 6import busio
 7import adafruit_scd30
 8
 9# SCD-30 has tempremental I2C with clock stretching, datasheet recommends
10# starting at 50KHz
11i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
12scd = adafruit_scd30.SCD30(i2c)
13
14while True:
15    # since the measurement interval is long (2+ seconds) we check for new data before reading
16    # the values, to ensure current readings.
17    if scd.data_available:
18        print("Data Available!")
19        print("CO2: %d PPM" % scd.CO2)
20        print("Temperature: %0.2f degrees C" % scd.temperature)
21        print("Humidity: %0.2f %% rH" % scd.relative_humidity)
22        print("")
23        print("Waiting for new data...")
24        print("")
25
26    time.sleep(0.5)

Tuning Knobs

Experiment with different tuning parameters and settings

examples/scd30_tuning_knobs.py
 1# SPDX-FileCopyrightText: 2020 by Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5import board
 6import busio
 7import adafruit_scd30
 8
 9# SCD-30 has tempremental I2C with clock stretching, datasheet recommends
10# starting at 50KHz
11i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
12scd = adafruit_scd30.SCD30(i2c)
13# scd.temperature_offset = 10
14print("Temperature offset:", scd.temperature_offset)
15
16# scd.measurement_interval = 4
17print("Measurement interval:", scd.measurement_interval)
18
19# scd.self_calibration_enabled = True
20print("Self-calibration enabled:", scd.self_calibration_enabled)
21
22# scd.ambient_pressure = 1100
23print("Ambient Pressure:", scd.ambient_pressure)
24
25# scd.altitude = 100
26print("Altitude:", scd.altitude, "meters above sea level")
27
28# scd.forced_recalibration_reference = 409
29print("Forced recalibration reference:", scd.forced_recalibration_reference)
30print("")
31
32while True:
33    data = scd.data_available
34    if data:
35        print("Data Available!")
36        print("CO2:", scd.CO2, "PPM")
37        print("Temperature:", scd.temperature, "degrees C")
38        print("Humidity::", scd.relative_humidity, "%%rH")
39        print("")
40        print("Waiting for new data...")
41        print("")
42
43    time.sleep(0.5)

MCP2221 and SCD30 Example

MCP2221 is known to not like the SCD30. Here is how to avoid this!

examples/scd30_tuning_knobs.py
 1# SPDX-FileCopyrightText: 2020 by Bryan Siepert, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4import time
 5import board
 6import busio
 7import adafruit_scd30
 8
 9# SCD-30 has tempremental I2C with clock stretching, datasheet recommends
10# starting at 50KHz
11i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
12scd = adafruit_scd30.SCD30(i2c)
13# scd.temperature_offset = 10
14print("Temperature offset:", scd.temperature_offset)
15
16# scd.measurement_interval = 4
17print("Measurement interval:", scd.measurement_interval)
18
19# scd.self_calibration_enabled = True
20print("Self-calibration enabled:", scd.self_calibration_enabled)
21
22# scd.ambient_pressure = 1100
23print("Ambient Pressure:", scd.ambient_pressure)
24
25# scd.altitude = 100
26print("Altitude:", scd.altitude, "meters above sea level")
27
28# scd.forced_recalibration_reference = 409
29print("Forced recalibration reference:", scd.forced_recalibration_reference)
30print("")
31
32while True:
33    data = scd.data_available
34    if data:
35        print("Data Available!")
36        print("CO2:", scd.CO2, "PPM")
37        print("Temperature:", scd.temperature, "degrees C")
38        print("Humidity::", scd.relative_humidity, "%%rH")
39        print("")
40        print("Waiting for new data...")
41        print("")
42
43    time.sleep(0.5)