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