/ README.rst
README.rst
1 2 Introduction 3 ============ 4 5 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-sgp30/badge/?version=latest 6 :target: https://circuitpython.readthedocs.io/projects/sgp30/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 14 .. image:: https://github.com/adafruit/Adafruit_CircuitPython_SGP30/workflows/Build%20CI/badge.svg 15 :target: https://github.com/adafruit/Adafruit_CircuitPython_SGP30/actions/ 16 :alt: Build Status 17 18 A CircuitPython driver for the Sensirion SGP30 gas sensor with eCO2 and TVOC output. This sensor uses I2C! 19 20 Installation and Dependencies 21 ============================= 22 This driver depends on: 23 24 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 25 * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ 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-sgp30/>`_. To install for current user: 36 37 .. code-block:: shell 38 39 pip3 install adafruit-circuitpython-sgp30 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-sgp30 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-sgp30 55 56 Usage Notes 57 ============= 58 59 See `the guide <https://learn.adafruit.com/adafruit-sgp30-gas-tvoc-eco2-mox-sensor/circuitpython-wiring-test>`_ 60 for wiring and installation instructions. 61 62 First, import the library: 63 64 .. code-block:: python 65 66 import busio 67 import adafruit_sgp30 68 69 Next, initialize the I2C bus object: 70 71 .. code-block:: python 72 73 import board 74 i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=100000) 75 76 Since we have the I2C bus object, we can now use it to instantiate the SGP30 object: 77 78 .. code-block:: python 79 80 sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus) 81 82 Reading from the Sensor 83 ------------------------ 84 85 To read from the sensor: 86 87 .. code-block:: python 88 89 eCO2, TVOC = sgp30.iaq_measure() 90 print("eCO2 = %d ppm \t TVOC = %d ppb" % (eCO2, TVOC)) 91 92 93 Contributing 94 ============ 95 96 Contributions are welcome! Please read our `Code of Conduct 97 <https://github.com/adafruit/Adafruit_CircuitPython_sgp30/blob/master/CODE_OF_CONDUCT.md>`_ 98 before contributing to help this project stay welcoming. 99 100 Documentation 101 ============= 102 103 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>`_.