/ README.rst
README.rst
  1  Introduction
  2  ============
  3  
  4  .. image:: https://readthedocs.org/projects/adafruit-circuitpython-si7021/badge/?version=latest
  5      :target: https://circuitpython.readthedocs.io/projects/si7021/en/latest/
  6      :alt: Documentation Status
  7  
  8  .. image:: https://img.shields.io/discord/327254708534116352.svg
  9      :target: https://adafru.it/discord
 10      :alt: Discord
 11  
 12  .. image:: https://github.com/adafruit/Adafruit_CircuitPython_SI7021/workflows/Build%20CI/badge.svg
 13      :target: https://github.com/adafruit/Adafruit_CircuitPython_SI7021/actions/
 14      :alt: Build Status
 15  
 16  CircuitPython module for use with the SI7021 Temperature and Humidity Sensor.
 17  
 18  Dependencies
 19  =============
 20  This driver depends on:
 21  
 22  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 23  * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
 24  
 25  Please ensure all dependencies are available on the CircuitPython filesystem.
 26  This is easily achieved by downloading
 27  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 28  
 29  Installing from PyPI
 30  ====================
 31  
 32  On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
 33  PyPI <https://pypi.org/project/adafruit-circuitpython-si7021/>`_. To install for current user:
 34  
 35  .. code-block:: shell
 36  
 37      pip3 install adafruit-circuitpython-si7021
 38  
 39  To install system-wide (this may be required in some cases):
 40  
 41  .. code-block:: shell
 42  
 43      sudo pip3 install adafruit-circuitpython-si7021
 44  
 45  To install in a virtual environment in your current project:
 46  
 47  .. code-block:: shell
 48  
 49      mkdir project-name && cd project-name
 50      python3 -m venv .env
 51      source .env/bin/activate
 52      pip3 install adafruit-circuitpython-si7021
 53      
 54  Usage Notes
 55  ===========
 56  
 57  Of course, you must import the library to use it:
 58  
 59  .. code:: python
 60  
 61      import adafruit_si7021
 62  
 63  This driver takes an instantiated and active I2C object (from the ``busio`` or
 64  the ``bitbangio`` library) as an argument to its constructor.  The way to create
 65  an I2C object depends on the board you are using. For boards with labeled SCL
 66  and SDA pins, you can:
 67  
 68  .. code:: python
 69  
 70      from busio import I2C
 71      from board import SCL, SDA
 72  
 73      i2c = I2C(SCL, SDA)
 74  
 75  Once you have created the I2C interface object, you can use it to instantiate
 76  the sensor object:
 77  
 78  .. code:: python
 79  
 80      sensor = adafruit_si7021.SI7021(i2c)
 81  
 82  
 83  And then you can start measuring the temperature and humidity:
 84  
 85  .. code:: python
 86  
 87      print(sensor.temperature)
 88      print(sensor.relative_humidity)
 89  
 90  
 91  Contributing
 92  ============
 93  
 94  Contributions are welcome! Please read our `Code of Conduct
 95  <https://github.com/adafruit/Adafruit_CircuitPython_SI7021/blob/master/CODE_OF_CONDUCT.md>`_
 96  before contributing to help this project stay welcoming.
 97  
 98  Documentation
 99  =============
100  
101  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>`_.