Skip to content

Commit e7d04a6

Browse files
committed
slow down every example
1 parent 4aede41 commit e7d04a6

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

examples/scd30_ft232htest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: 2020 by Bryan Siepert, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
import time
5+
import board
6+
import busio
7+
import adafruit_scd30
8+
9+
# SCD-30 has tempremental I2C with clock stretching, and delays
10+
# It's best to start using I2C clock slower and then you can increase it
11+
# until the sensor stops responding (NAK fails, etc)
12+
i2c = busio.I2C(board.SCL, board.SDA, frequency=1000) # for FT232H, use 1KHz
13+
scd = adafruit_scd30.SCD30(i2c)
14+
15+
while True:
16+
# since the measurement interval is long (2+ seconds) we check for new data before reading
17+
# the values, to ensure current readings.
18+
if scd.data_available:
19+
print("Data Available!")
20+
print("CO2: %d PPM" % scd.CO2)
21+
print("Temperature: %0.2f degrees C" % scd.temperature)
22+
print("Humidity: %0.2f %% rH" % scd.relative_humidity)
23+
print("")
24+
print("Waiting for new data...")
25+
print("")
26+
27+
time.sleep(0.5)

examples/scd30_mcp2221test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# SPDX-License-Identifier: Unlicense
44
import time
55
import board
6+
import busio
67
import adafruit_scd30
78

8-
i2c = board.I2C() # uses board.SCL and board.SDA
9+
# SCD-30 has tempremental I2C with clock stretching, datasheet recommends
10+
# starting at 50KHz
11+
i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
912
scd = adafruit_scd30.SCD30(i2c)
1013

1114
# The SCD30 reset generates a hiccup on the SCL and SDA lines

examples/scd30_simpletest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
import busio
77
import adafruit_scd30
88

9-
# SCD-30 has tempremental I2C with clock stretching, and delays
10-
# It's best to start using I2C clock slower and then you can increase it
11-
# until the sensor stops responding (NAK fails, etc)
12-
#i2c = busio.I2C(board.SCL, board.SDA, frequency=1000) # for FT232H, use 1KHz
13-
i2c = busio.I2C(board.SCL, board.SDA, frequency=50000) # for MCP2221 and others, use 50KHz
9+
# SCD-30 has tempremental I2C with clock stretching, datasheet recommends
10+
# starting at 50KHz
11+
i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
1412
scd = adafruit_scd30.SCD30(i2c)
1513

1614
while True:

examples/scd30_tuning_knobs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# SPDX-License-Identifier: Unlicense
44
import time
55
import board
6+
import busio
67
import adafruit_scd30
78

8-
i2c = board.I2C() # uses board.SCL and board.SDA
9+
# SCD-30 has tempremental I2C with clock stretching, datasheet recommends
10+
# starting at 50KHz
11+
i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
912
scd = adafruit_scd30.SCD30(i2c)
1013
# scd.temperature_offset = 10
1114
print("Temperature offset:", scd.temperature_offset)

0 commit comments

Comments
 (0)