From cec927f078c2c8952ff842ee84cf6b1a619ee006 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Fri, 16 Apr 2021 08:07:37 -0400 Subject: [PATCH 1/2] Improving docs an changing example to reflect changes in the readme.rst --- adafruit_ahtx0.py | 40 ++++++++++++++++++++++++++++++++---- examples/ahtx0_simpletest.py | 8 +++++++- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/adafruit_ahtx0.py b/adafruit_ahtx0.py index cff1d87..dab8d45 100644 --- a/adafruit_ahtx0.py +++ b/adafruit_ahtx0.py @@ -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 @@ -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:** @@ -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 @@ -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 diff --git a/examples/ahtx0_simpletest.py b/examples/ahtx0_simpletest.py index 2d44043..c835127 100644 --- a/examples/ahtx0_simpletest.py +++ b/examples/ahtx0_simpletest.py @@ -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) From 21d0e425da6d9e77f40b5adc37893b55575453ed Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Fri, 16 Apr 2021 08:15:05 -0400 Subject: [PATCH 2/2] Including description in related products --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 151d0e7..13c8720 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,7 +26,7 @@ Table of Contents .. toctree:: :caption: Related Products - https://www.adafruit.com/product/4566 + Adafruit AHT20 - Temperature & Humidity Sensor Breakout Board .. toctree:: :caption: Other Links