Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaked example code. Tested on Feather M4. #24

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions examples/ccs811_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import time

from board import SCL, SDA
import board
import busio

import adafruit_ccs811

i2c_bus = busio.I2C(SCL, SDA)

ccs = adafruit_ccs811.CCS811(i2c_bus)
i2c = busio.I2C(board.SCL, board.SDA)
ccs811 = adafruit_ccs811.CCS811(i2c)

#wait for the sensor to be ready and calibrate the thermistor
while not ccs.data_ready:
# Wait for the sensor to be ready and calibrate the thermistor
while not ccs811.data_ready:
pass
temp = ccs.temperature
ccs.temp_offset = temp - 25.0
temp = ccs811.temperature
ccs811.temp_offset = temp - 25.0

while True:
print("CO2: ", ccs.eco2, " TVOC:", ccs.tvoc, " temp:", ccs.temperature)
time.sleep(.5)
print("CO2: {} PPM, TVOC: {} PPM, Temp: {} C"
.format(ccs811.eco2, ccs811.tvoc, ccs811.temperature))
time.sleep(0.5)