Skip to content

Commit 26a2ffd

Browse files
authored
Merge pull request #24 from kattni/update-example
Tweaked example code. Tested on Feather M4.
2 parents ecd081c + e821489 commit 26a2ffd

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

examples/ccs811_simpletest.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import time
2-
3-
from board import SCL, SDA
2+
import board
43
import busio
5-
64
import adafruit_ccs811
75

8-
i2c_bus = busio.I2C(SCL, SDA)
9-
10-
ccs = adafruit_ccs811.CCS811(i2c_bus)
6+
i2c = busio.I2C(board.SCL, board.SDA)
7+
ccs811 = adafruit_ccs811.CCS811(i2c)
118

12-
#wait for the sensor to be ready and calibrate the thermistor
13-
while not ccs.data_ready:
9+
# Wait for the sensor to be ready and calibrate the thermistor
10+
while not ccs811.data_ready:
1411
pass
15-
temp = ccs.temperature
16-
ccs.temp_offset = temp - 25.0
12+
temp = ccs811.temperature
13+
ccs811.temp_offset = temp - 25.0
1714

1815
while True:
19-
print("CO2: ", ccs.eco2, " TVOC:", ccs.tvoc, " temp:", ccs.temperature)
20-
time.sleep(.5)
16+
print("CO2: {} PPM, TVOC: {} PPM, Temp: {} C"
17+
.format(ccs811.eco2, ccs811.tvoc, ccs811.temperature))
18+
time.sleep(0.5)

0 commit comments

Comments
 (0)