Skip to content

Commit a12bb11

Browse files
Merge pull request #20 from jposada202020/improving_docs
Improving_docs
2 parents ebb8c7c + 88cec64 commit a12bb11

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

adafruit_am2320.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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://github.com/adafruit/circuitpython/releases
2525
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2626
2727
"""
@@ -63,8 +63,34 @@ def _crc16(data):
6363
class AM2320:
6464
"""A driver for the AM2320 temperature and humidity sensor.
6565
66-
:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
67-
:param int address: (optional) The I2C address of the device.
66+
:param ~busio.I2C i2c_bus: The I2C bus the AM2320 is connected to.
67+
This is the only required parameter.
68+
:param int address: (optional) The I2C address of the device. Defaults to :const:`0x5C`
69+
70+
**Quickstart: Importing and using the AM2320**
71+
72+
Here is an example of using the :class:`AM2320` class.
73+
First you will need to import the libraries to use the sensor
74+
75+
.. code-block:: python
76+
77+
import board
78+
import adafruit_am2320
79+
80+
Once this is done you can define your `board.I2C` object and define your sensor object
81+
82+
.. code-block:: python
83+
84+
i2c = board.I2C() # uses board.SCL and board.SDA
85+
am = adafruit_am2320.AM2320(i2c)
86+
87+
Now you have access to the temperature using :attr:`temperature` attribute and
88+
the relative humidity using the :attr:`relative_humidity` attribute
89+
90+
.. code-block:: python
91+
92+
temperature = am.temperature
93+
relative_humidity = am.relative_humidity
6894
6995
"""
7096

@@ -108,7 +134,7 @@ def _read_register(self, register, length):
108134

109135
@property
110136
def temperature(self):
111-
"""The measured temperature in celsius."""
137+
"""The measured temperature in Celsius."""
112138
temperature = struct.unpack(">H", self._read_register(AM2320_REG_TEMP_H, 2))[0]
113139
if temperature >= 32768:
114140
temperature = 32768 - temperature

docs/index.rst

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

26+
Adafruit AM2320 Temperature and Humidity Sensor Learning Guide <https://learn.adafruit.com/adafruit-am2320-temperature-humidity-i2c-sensor/python-circuitpython>
2627

2728
.. toctree::
2829
:caption: Related Products
2930

31+
Adafruit AM2320 Temperature and Humidity Sensor <https://www.adafruit.com/product/3721>
3032

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

examples/am2320_simpletest.py

Lines changed: 1 addition & 2 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_am2320
87

98
# create the I2C shared bus
10-
i2c = busio.I2C(board.SCL, board.SDA)
9+
i2c = board.I2C() # uses board.SCL and board.SDA
1110
am = adafruit_am2320.AM2320(i2c)
1211

1312
while True:

0 commit comments

Comments
 (0)