Skip to content

Commit f12be3b

Browse files
Merge pull request #20 from jposada202020/improving_docs
-Improving docs
2 parents c91a67a + 34052b6 commit f12be3b

7 files changed

+64
-23
lines changed

README.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ You must import the library to use it:
6363
6464
This driver takes an instantiated and active I2C object (from the `busio` or
6565
the `bitbangio` library) as an argument to its constructor. The way to create
66-
an I2C object depends on the board you are using. For boards with labeled SCL
67-
and SDA pins, you can:
66+
an I2C object depends on the board you are using.
6867

6968
.. code:: python
7069
71-
from busio import I2C
72-
from board import SCL, SDA
70+
from board
7371
74-
i2c = I2C(SCL, SDA)
72+
i2c = board.I2C()
7573
7674
Once you have created the I2C interface object, you can use it to instantiate
7775
the sensor object:

adafruit_sht31d.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
1717
**Hardware:**
1818
19-
* Adafruit `Sensiron SHT31-D Temperature & Humidity Sensor Breakout
20-
<https://www.adafruit.com/product/2857>`_ (Product ID: 2857)
19+
* Adafruit SHT31-D temperature and humidity sensor Breakout: https://www.adafruit.com/product/2857
2120
2221
**Software and Dependencies:**
2322
24-
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
25-
https://github.com/adafruit/circuitpython/releases
23+
* Adafruit CircuitPython firmware for the supported boards:
24+
https://circuitpython.org/downloads
25+
2626
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2727
"""
2828

@@ -145,8 +145,35 @@ class SHT31D:
145145
"""
146146
A driver for the SHT31-D temperature and humidity sensor.
147147
148-
:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
149-
:param int address: (optional) The I2C address of the device.
148+
:param ~busio.I2C i2c_bus: The I2C bus the SHT31-D is connected to
149+
:param int address: (optional) The I2C address of the device. Defaults to :const:`0x44`
150+
151+
**Quickstart: Importing and using the SHT31-D**
152+
153+
Here is an example of using the :class:`SHT31D` class.
154+
First you will need to import the libraries to use the sensor
155+
156+
.. code-block:: python
157+
158+
import board
159+
import adafruit_sht31d
160+
161+
Once this is done you can define your `board.I2C` object and define your sensor object
162+
163+
.. code-block:: python
164+
165+
i2c = board.I2C() # uses board.SCL and board.SDA
166+
sht = adafruit_sht31d.SHT31D(i2c)
167+
168+
Now you have access to the temperature and humidity the
169+
the :attr:`temperature` and :attr:`relative_humidity` attributes
170+
171+
172+
.. code-block:: python
173+
174+
temperature = sht.temperature
175+
humidity = sht.relative_humidity
176+
150177
"""
151178

152179
def __init__(self, i2c_bus, address=_SHT31_DEFAULT_ADDRESS):
@@ -326,7 +353,7 @@ def frequency(self, value):
326353
@property
327354
def temperature(self):
328355
"""
329-
The measured temperature in degrees celsius.
356+
The measured temperature in degrees Celsius.
330357
'Single' mode reads and returns the current temperature as a float.
331358
'Periodic' mode returns the most recent readings available from the sensor's cache
332359
in a FILO list of eight floats. This list is backfilled with with the

docs/examples.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,21 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/sht31d_simpletest.py
77
:caption: examples/sht31d_simpletest.py
88
:linenos:
9+
10+
Simple Mode
11+
------------
12+
13+
Example in how to use the sensor in simple mode
14+
15+
.. literalinclude:: ../examples/sht31d_simple_mode.py
16+
:caption: examples/sht31d_simple_mode.py
17+
:linenos:
18+
19+
Periodic Mode
20+
-------------
21+
22+
Example in how to use the sensor in periodic mode
23+
24+
.. literalinclude:: ../examples/sht31d_simpletest.py
25+
:caption: examples/sht31d_simpletest.py
26+
:linenos:

docs/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit Sensirion SHT31-D Temperature & Humidity Sensor Breakout <https://learn.adafruit.com/adafruit-sht31-d-temperature-and-humidity-sensor-breakout>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

29-
Adafruit Sensiron SHT31-D Temperature & Humidity Sensor Breakout <https://www.adafruit.com/product/2857>
31+
Adafruit Sensirion SHT31-D Temperature & Humidity Sensor Breakout <https://www.adafruit.com/product/2857>
3032

3133
.. toctree::
3234
:caption: Other Links

examples/sht31d_periodic_mode.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4-
#!/usr/bin/python3
54
import time
65
import board
7-
import busio
86
import adafruit_sht31d
97

10-
# Create library object using our Bus I2C port
11-
i2c = busio.I2C(board.SCL, board.SDA)
8+
# Create sensor object, communicating over the board's default I2C bus
9+
i2c = board.I2C()
1210
sensor = adafruit_sht31d.SHT31D(i2c)
1311

1412
print("\033[1mSensor\033[0m = SHT31-D")

examples/sht31d_simple_mode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# SPDX-License-Identifier: MIT
33

44
import board
5-
import busio
65
import adafruit_sht31d
76

8-
# Create library object using our Bus I2C port
9-
i2c = busio.I2C(board.SCL, board.SDA)
7+
# Create sensor object, communicating over the board's default I2C bus
8+
i2c = board.I2C()
109
sensor = adafruit_sht31d.SHT31D(i2c)
1110

1211
print("\033[1mSensor\033[0m = SHT31-D")

examples/sht31d_simpletest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
import time
55
import board
6-
import busio
76
import adafruit_sht31d
87

9-
# Create library object using our Bus I2C port
10-
i2c = busio.I2C(board.SCL, board.SDA)
8+
# Create sensor object, communicating over the board's default I2C bus
9+
i2c = board.I2C()
1110
sensor = adafruit_sht31d.SHT31D(i2c)
1211

1312
loopcount = 0

0 commit comments

Comments
 (0)