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.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-ccs811
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-ccs811
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-ccs811
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 simply read the attributes:
print("CO2: ", ccs.eco2, " TVOC:", ccs.tvoc)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
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 | 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
while not ccs811.data_ready:
pass
while True:
print("CO2: {} PPM, TVOC: {} PPB".format(ccs811.eco2, ccs811.tvoc))
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
¶ Deprecated since version 1.1.5: Hardware support removed by vendor
Temperature based on optional thermistor in Celsius.
-
tvoc
¶ Total Volatile Organic Compound in parts per billion.
-
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line