-
Notifications
You must be signed in to change notification settings - Fork 24
Tweaked example code. Tested on Feather M4. #24
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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_bus = busio.I2C(board.SCL, board.SDA) | ||
ccs811 = adafruit_ccs811.CCS811(i2c_bus) | ||
|
||
#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: %1.0f PPM, TVOC: %1.0f PPM, Temp: %0.1f C" % | ||
(ccs811.eco2, ccs811.tvoc, ccs811.temperature)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I didn't realise it was considered to be the old way. I'll refactor it. |
||
time.sleep(0.5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i2c_bus
or justi2c
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had
i2c
. Must have pasted the wrong update at some point in going back and forth between code.py and simpletest.