Skip to content

Improving docs #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions adafruit_si7021.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MIT

"""
``adafruit_si7021``
`adafruit_si7021`
===================

This is a CircuitPython driver for the SI7021 temperature and humidity sensor.
Expand All @@ -20,8 +20,8 @@

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
try:
Expand Down Expand Up @@ -91,8 +91,36 @@ class SI7021:
"""
A driver for the SI7021 temperature and humidity sensor.

:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
:param int address: (optional) The I2C address of the device.
:param i2c_bus: The `busio.I2C` object to use.
:param int address: The I2C device address for the sensor. Default is :const:`0x40`

**Quickstart: Importing and using the SI7021 temperature and humidity sensor**

Here is one way of importing the `SI7021` class so you can use it
with the name ``si_sensor``.
First you will need to import the libraries to use the sensor

.. code-block:: python

import busio
import board
import adafruit_si7021

Once this is done you can define your `busio.I2C` object and define your sensor object

.. code-block:: python

i2c = busio.I2C(board.SCL, board.SDA)
si_sensor = adafruit_si7021.SI7021(i2c)

Now you have access to the temperature and humidity using
:attr:`temperature` and :attr:`relative_humidity` attributes

.. code-block:: python

temperature = si_sensor.temperature
relative_humidity = si_sensor.relative_humidity

"""

def __init__(self, i2c_bus, address=0x40):
Expand Down Expand Up @@ -146,7 +174,7 @@ def relative_humidity(self):

@property
def temperature(self):
"""The measured temperature in degrees Celcius."""
"""The measured temperature in degrees Celsius."""
self.start_measurement(TEMPERATURE)
value = self._data()
self._measurement = 0
Expand All @@ -159,7 +187,7 @@ def start_measurement(self, what):
Starts a measurement of either ``HUMIDITY`` or ``TEMPERATURE``
depending on the ``what`` argument. Returns immediately, and the
result of the measurement can be retrieved with the
``temperature`` and ``relative_humidity`` properties. This way it
:attr:`temperature` and :attr:`relative_humidity` properties. This way it
will take much less time.

This can be useful if you want to start the measurement, but don't
Expand Down