Skip to content

Commit f879a26

Browse files
authored
Merge pull request #22 from jposada202020/improving_docs
Improving docs
2 parents a20973b + 9d39d76 commit f879a26

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

adafruit_si7021.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
"""
6-
``adafruit_si7021``
6+
`adafruit_si7021`
77
===================
88
99
This is a CircuitPython driver for the SI7021 temperature and humidity sensor.
@@ -20,8 +20,8 @@
2020
2121
**Software and Dependencies:**
2222
23-
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
24-
https://github.com/adafruit/circuitpython/releases
23+
* Adafruit CircuitPython firmware for the supported boards:
24+
https://circuitpython.org/downloads
2525
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2626
"""
2727
try:
@@ -91,8 +91,36 @@ class SI7021:
9191
"""
9292
A driver for the SI7021 temperature and humidity sensor.
9393
94-
:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
95-
:param int address: (optional) The I2C address of the device.
94+
:param i2c_bus: The `busio.I2C` object to use.
95+
:param int address: The I2C device address for the sensor. Default is :const:`0x40`
96+
97+
**Quickstart: Importing and using the SI7021 temperature and humidity sensor**
98+
99+
Here is one way of importing the `SI7021` class so you can use it
100+
with the name ``si_sensor``.
101+
First you will need to import the libraries to use the sensor
102+
103+
.. code-block:: python
104+
105+
import busio
106+
import board
107+
import adafruit_si7021
108+
109+
Once this is done you can define your `busio.I2C` object and define your sensor object
110+
111+
.. code-block:: python
112+
113+
i2c = busio.I2C(board.SCL, board.SDA)
114+
si_sensor = adafruit_si7021.SI7021(i2c)
115+
116+
Now you have access to the temperature and humidity using
117+
:attr:`temperature` and :attr:`relative_humidity` attributes
118+
119+
.. code-block:: python
120+
121+
temperature = si_sensor.temperature
122+
relative_humidity = si_sensor.relative_humidity
123+
96124
"""
97125

98126
def __init__(self, i2c_bus, address=0x40):
@@ -146,7 +174,7 @@ def relative_humidity(self):
146174

147175
@property
148176
def temperature(self):
149-
"""The measured temperature in degrees Celcius."""
177+
"""The measured temperature in degrees Celsius."""
150178
self.start_measurement(TEMPERATURE)
151179
value = self._data()
152180
self._measurement = 0
@@ -159,7 +187,7 @@ def start_measurement(self, what):
159187
Starts a measurement of either ``HUMIDITY`` or ``TEMPERATURE``
160188
depending on the ``what`` argument. Returns immediately, and the
161189
result of the measurement can be retrieved with the
162-
``temperature`` and ``relative_humidity`` properties. This way it
190+
:attr:`temperature` and :attr:`relative_humidity` properties. This way it
163191
will take much less time.
164192
165193
This can be useful if you want to start the measurement, but don't

0 commit comments

Comments
 (0)