Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Usage Notes¶
See the guide for wiring and installation instructions.
Of course, you must import the library to use it:
import busio
import adafruit_CCS811
Next, initialize the I2C bus object.
from board import *
i2c_bus = busio.I2C(SCL, SDA)
Once you have created the I2C interface object, you can use it to instantiate the CCS811 object
ccs = adafruit_ccs811.CCS811(i2c_bus)
Reading Sensor¶
To read the gas sensor and temperature simply read the attributes:
print("CO2: ", ccs.eco2, " TVOC:", ccs.tvoc, " temp:", ccs.temperature)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Building locally¶
To build this library locally you’ll need to install the circuitpython-build-tools package.
python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools
Once installed, make sure you are in the virtual environment:
source .env/bin/activate
Then run the build:
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ccs811 --library_location .
Sphinx documentation¶
Sphinx is used to build the documentation based on rST files and comments in the code. First, install dependencies (feel free to reuse the virtual environment from above):
python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme
Now, once you have the virtual environment activated:
cd docs
sphinx-build -E -W -b html . _build/html
This will output the documentation to docs/_build/html
. Open the index.html in your browser to
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
locally verify it will pass.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import time
import board
import busio
import adafruit_ccs811
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 ccs811.data_ready:
pass
temp = ccs811.temperature
ccs811.temp_offset = temp - 25.0
while True:
print("CO2: {} PPM, TVOC: {} PPM, Temp: {} C"
.format(ccs811.eco2, ccs811.tvoc, ccs811.temperature))
time.sleep(0.5)
|
CCS811
- Adafruit CCS811 Air Quality Sensor Breakout - VOC and eCO2¶
This library supports the use of the CCS811 air quality sensor in CircuitPython.
Author(s): Dean Miller for Adafruit Industries
Notes:
#. Datasheet
-
class
adafruit_ccs811.
CCS811
(i2c_bus, address=90)[source]¶ CCS811 gas sensor driver.
Parameters: -
data_ready
¶ True when new data has been read.
-
eco2
¶ Equivalent Carbon Dioxide in parts per million. Clipped to 400 to 8192ppm.
-
error
¶ True when an error has occured.
-
error_code
¶ Error code
-
set_environmental_data
(humidity, temperature)[source]¶ Set the temperature and humidity used when computing eCO2 and TVOC values.
Parameters:
-
set_interrupt_thresholds
(low_med, med_high, hysteresis)[source]¶ Set the thresholds used for triggering the interrupt based on eCO2. The interrupt is triggered when the value crossed a boundary value by the minimum hysteresis value.
Parameters:
-
temp_offset
= 0.0¶ Temperature offset.
-
temperature
¶ Temperature based on optional thermistor in Celsius.
-
tvoc
¶ Total Volatile Organic Compound in parts per billion.
-