Skip to content

Commit 856c271

Browse files
authored
Merge pull request #5 from jposada202020/improving_docs
Improving docs
2 parents 6ab98fc + 21d0e42 commit 856c271

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

adafruit_ahtx0.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
`adafruit_ahtx0`
77
================================================================================
88
9-
CircuitPython driver for the Adafruit AHT10 Humidity and Temperature Sensor
9+
CircuitPython driver for the Adafruit AHT10/AHT20 Temperature & Humidity Sensor
1010
1111
1212
* Author(s): Kattni Rembor
@@ -16,7 +16,7 @@
1616
1717
**Hardware:**
1818
19-
* This is a library for the Adafruit AHT20 breakout:
19+
* This is a library for the Adafruit AHT20 Temperature & Humidity Sensor breakout:
2020
https://www.adafruit.com/product/4566
2121
2222
**Software and Dependencies:**
@@ -42,7 +42,39 @@
4242

4343

4444
class AHTx0:
45-
"""Interface library for AHT10/AHT20 temperature+humidity sensors"""
45+
"""
46+
Interface library for AHT10/AHT20 temperature+humidity sensors
47+
48+
:param ~busio.I2C i2c_bus: The I2C bus the AHT10/AHT20 is connected to.
49+
:param address: The I2C device address for the sensor. Default is :const:`0x38`
50+
51+
**Quickstart: Importing and using the AHT10/AHT20 temperature sensor**
52+
53+
Here is one way of importing the `AHTx0` class so you can use it with the name ``aht``.
54+
First you will need to import the libraries to use the sensor
55+
56+
.. code-block:: python
57+
58+
import busio
59+
import board
60+
import adafruit_ahtx0
61+
62+
Once this is done you can define your `busio.I2C` object and define your sensor object
63+
64+
.. code-block:: python
65+
66+
i2c = busio.I2C(board.SCL, board.SDA)
67+
aht = adafruit_ahtx0.AHTx0(i2c)
68+
69+
Now you have access to the temperature and humidity using
70+
the :attr:`temperature` and :attr:`relative_humidity` attributes
71+
72+
.. code-block:: python
73+
74+
temperature = aht.temperature
75+
relative_humidity = aht.relative_humidity
76+
77+
"""
4678

4779
def __init__(self, i2c_bus, address=AHTX0_I2CADDR_DEFAULT):
4880
time.sleep(0.02) # 20ms delay to wake up
@@ -90,7 +122,7 @@ def relative_humidity(self):
90122

91123
@property
92124
def temperature(self):
93-
"""The measured temperature in degrees Celcius."""
125+
"""The measured temperature in degrees Celsius."""
94126
self._readdata()
95127
return self._temp
96128

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Table of Contents
2626
.. toctree::
2727
:caption: Related Products
2828

29-
https://www.adafruit.com/product/4566
29+
Adafruit AHT20 - Temperature & Humidity Sensor Breakout Board <https://www.adafruit.com/product/4566>
3030

3131
.. toctree::
3232
:caption: Other Links

examples/ahtx0_simpletest.py

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

4+
"""
5+
Basic `AHTx0` example test
6+
"""
7+
48
import time
59
import board
10+
import busio
611
import adafruit_ahtx0
712

813
# Create the sensor object using I2C
9-
sensor = adafruit_ahtx0.AHTx0(board.I2C())
14+
i2c = busio.I2C(board.SCL, board.SDA)
15+
sensor = adafruit_ahtx0.AHTx0(i2c)
1016

1117
while True:
1218
print("\nTemperature: %0.1f C" % sensor.temperature)

0 commit comments

Comments
 (0)