Skip to content

Improving docs #5

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 2 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
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
40 changes: 36 additions & 4 deletions adafruit_ahtx0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
`adafruit_ahtx0`
================================================================================

CircuitPython driver for the Adafruit AHT10 Humidity and Temperature Sensor
CircuitPython driver for the Adafruit AHT10/AHT20 Temperature & Humidity Sensor


* Author(s): Kattni Rembor
Expand All @@ -16,7 +16,7 @@

**Hardware:**

* This is a library for the Adafruit AHT20 breakout:
* This is a library for the Adafruit AHT20 Temperature & Humidity Sensor breakout:
https://www.adafruit.com/product/4566

**Software and Dependencies:**
Expand All @@ -42,7 +42,39 @@


class AHTx0:
"""Interface library for AHT10/AHT20 temperature+humidity sensors"""
"""
Interface library for AHT10/AHT20 temperature+humidity sensors

:param ~busio.I2C i2c_bus: The I2C bus the AHT10/AHT20 is connected to.
:param address: The I2C device address for the sensor. Default is :const:`0x38`

**Quickstart: Importing and using the AHT10/AHT20 temperature sensor**

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

.. code-block:: python

import busio
import board
import adafruit_ahtx0

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)
aht = adafruit_ahtx0.AHTx0(i2c)

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

.. code-block:: python

temperature = aht.temperature
relative_humidity = aht.relative_humidity

"""

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

@property
def temperature(self):
"""The measured temperature in degrees Celcius."""
"""The measured temperature in degrees Celsius."""
self._readdata()
return self._temp

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Table of Contents
.. toctree::
:caption: Related Products

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

.. toctree::
:caption: Other Links
Expand Down
8 changes: 7 additions & 1 deletion examples/ahtx0_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
Basic `AHTx0` example test
"""

import time
import board
import busio
import adafruit_ahtx0

# Create the sensor object using I2C
sensor = adafruit_ahtx0.AHTx0(board.I2C())
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_ahtx0.AHTx0(i2c)

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