Adafruit_CircuitPython_CCS811/examples/ccs811_simpletest.py
2018-08-15 14:33:33 -04:00

18 lines
458 B
Python

import time
import board
import busio
import adafruit_ccs811
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 ccs811.data_ready:
pass
temp = ccs811.temperature
ccs811.temp_offset = temp - 25.0
while True:
print("CO2: %1.0f PPM, TVOC: %1.0f PPM, Temp: %0.1f C" %
(ccs811.eco2, ccs811.tvoc, ccs811.temperature))
time.sleep(0.5)