From 0cd1595ec1a5b1ab2e4739d87e5104fe1b308fb5 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Fri, 23 Apr 2021 18:45:44 -0400 Subject: [PATCH] adding board.I2C, adding learning guide, product description --- README.rst | 3 +-- adafruit_shtc3.py | 13 ++++++------- docs/index.rst | 3 ++- examples/shtc3_simpletest.py | 3 +-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index a9fe87c..4a4cdec 100644 --- a/README.rst +++ b/README.rst @@ -63,11 +63,10 @@ Usage Example .. code-block:: python3 import time - import busio import board import adafruit_shtc3 - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() # uses board.SCL and board.SDA sht = adafruit_shtc3.SHTC3(i2c) while True: diff --git a/adafruit_shtc3.py b/adafruit_shtc3.py index 93ef783..c672cd5 100644 --- a/adafruit_shtc3.py +++ b/adafruit_shtc3.py @@ -81,24 +81,23 @@ class SHTC3: """ A driver for the SHTC3 temperature and humidity sensor. - :param ~busio.I2C i2c_bus: The `busio.I2C` object to use. This is the only required parameter. + :param ~busio.I2C i2c_bus: The I2C bus the SHTC3 is connected to. **Quickstart: Importing and using the SHTC3 temperature and humidity sensor** - Here is one way of importing the `SHTC3` class so you can use it with the name ``sht``. - First you will need to import the helper libraries to use the sensor + Here is an example of using the :class:`SHTC3`. + First you will need to import the libraries to use the sensor .. code-block:: python - import busio import board import adafruit_shtc3 - Once this is done, you can define your `busio.I2C` object and define your sensor + Once this is done, you can define your `board.I2C` object and define your sensor .. code-block:: python - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() # uses board.SCL and board.SDA sht = adafruit_shtc3.SHTC3(i2c) Now you have access to the temperature and humidity using the :attr:`measurements`. @@ -146,7 +145,7 @@ def reset(self): self._write_command(_SHTC3_SOFTRESET) except RuntimeError as run_err: - if run_err.args and run_err.args[0] != "I2C slave address was NACK'd": + if run_err.args and run_err.args[0] != "I2C device address was NACK'd": raise run_err time.sleep(0.001) diff --git a/docs/index.rst b/docs/index.rst index c4b51d1..6488089 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,11 +23,12 @@ Table of Contents .. toctree:: :caption: Tutorials - + Adafruit Sensirion SHTC3 Temperature & Humidity Sensor Learning Guide .. toctree:: :caption: Related Products + Adafruit Sensirion SHTC3 Temperature & Humidity Sensor .. toctree:: :caption: Other Links diff --git a/examples/shtc3_simpletest.py b/examples/shtc3_simpletest.py index 7b3ea5a..5b967aa 100755 --- a/examples/shtc3_simpletest.py +++ b/examples/shtc3_simpletest.py @@ -2,11 +2,10 @@ # # SPDX-License-Identifier: MIT import time -import busio import board import adafruit_shtc3 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() sht = adafruit_shtc3.SHTC3(i2c) while True: