/ README.rst
README.rst
  1  
  2  Adafruit CircuitPython CCS811 Library
  3  =====================================
  4  
  5  .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ccs811/badge/?version=latest
  6      :target: https://circuitpython.readthedocs.io/projects/ccs811/en/latest/
  7      :alt: Documentation Status
  8  
  9  .. image :: https://img.shields.io/discord/327254708534116352.svg
 10      :target: https://adafru.it/discord
 11      :alt: Discord
 12  
 13  .. image:: https://github.com/adafruit/Adafruit_CircuitPython_CCS811/workflows/Build%20CI/badge.svg
 14      :target: https://github.com/adafruit/Adafruit_CircuitPython_CCS811/actions/
 15      :alt: Build Status
 16  
 17  CircuitPython driver for the `CCS811 air quality sensor <https://www.adafruit.com/product/3566>`_.
 18  
 19  Dependencies
 20  =============
 21  This driver depends on:
 22  
 23  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 24  * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
 25  * `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
 26  
 27  Please ensure all dependencies are available on the CircuitPython filesystem.
 28  This is easily achieved by downloading
 29  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 30  
 31  Installing from PyPI
 32  ====================
 33  
 34  On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
 35  PyPI <https://pypi.org/project/adafruit-circuitpython-ccs811/>`_. To install for current user:
 36  
 37  .. code-block:: shell
 38  
 39      pip3 install adafruit-circuitpython-ccs811
 40  
 41  To install system-wide (this may be required in some cases):
 42  
 43  .. code-block:: shell
 44  
 45      sudo pip3 install adafruit-circuitpython-ccs811
 46  
 47  To install in a virtual environment in your current project:
 48  
 49  .. code-block:: shell
 50  
 51      mkdir project-name && cd project-name
 52      python3 -m venv .env
 53      source .env/bin/activate
 54      pip3 install adafruit-circuitpython-ccs811
 55  
 56  Usage Notes
 57  ===========
 58  
 59  See `the guide <https://learn.adafruit.com/adafruit-ccs811-air-quality-sensor/python-circuitpython>`_
 60  for wiring and installation instructions.
 61  
 62  Of course, you must import the library to use it:
 63  
 64  .. code:: python
 65  
 66      import busio
 67      import adafruit_ccs811
 68  
 69  Next, initialize the I2C bus object.
 70  
 71  .. code:: python
 72  
 73      from board import *
 74      i2c_bus = busio.I2C(SCL, SDA)
 75  
 76  Once you have created the I2C interface object, you can use it to instantiate
 77  the CCS811 object
 78  
 79  .. code:: python
 80  
 81      ccs =  adafruit_ccs811.CCS811(i2c_bus)
 82  
 83  Reading Sensor
 84  --------------
 85  
 86  To read the gas sensor simply read the attributes:
 87  
 88  .. code:: python
 89  
 90      print("CO2: ", ccs.eco2, " TVOC:", ccs.tvoc)
 91  
 92  Contributing
 93  ============
 94  
 95  Contributions are welcome! Please read our `Code of Conduct
 96  <https://github.com/adafruit/Adafruit_CircuitPython_CCS811/blob/master/CODE_OF_CONDUCT.md>`_
 97  before contributing to help this project stay welcoming.
 98  
 99  Documentation
100  =============
101  
102  For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.