Skip to content

Commit eb94280

Browse files
committed
Tweaked example code. Tested on Feather M4.
1 parent ecd081c commit eb94280

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

examples/ccs811_simpletest.py

Lines changed: 10 additions & 12 deletions
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_bus = busio.I2C(board.SCL, board.SDA)
7+
ccs811 = adafruit_ccs811.CCS811(i2c_bus)
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: %1.0f PPM, TVOC: %1.0f PPM, Temp: %0.1f C" %
17+
(ccs811.eco2, ccs811.tvoc, ccs811.temperature))
18+
time.sleep(0.5)

0 commit comments

Comments
 (0)