diff --git a/README.rst b/README.rst index 716762b..c641c6d 100644 --- a/README.rst +++ b/README.rst @@ -60,10 +60,9 @@ Usage Example import time import board - import busio import adafruit_hts221 - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() hts = adafruit_hts221.HTS221(i2c) while True: print("Relative Humidity: %.2f percent rH" % hts.relative_humidity) diff --git a/adafruit_hts221.py b/adafruit_hts221.py index 00eabf5..2f32030 100644 --- a/adafruit_hts221.py +++ b/adafruit_hts221.py @@ -15,7 +15,8 @@ **Hardware:** -* `HTS221 Breakout `_ +* `Adafruit HTS221 - Temperature & Humidity + Sensor Breakout Board `_ **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: @@ -65,7 +66,7 @@ class CV: @classmethod def add_values(cls, value_tuples): - "creates CV entires" + """creates CV entries""" cls.string = {} cls.lsb = {} @@ -77,12 +78,12 @@ def add_values(cls, value_tuples): @classmethod def is_valid(cls, value): - "Returns true if the given value is a member of the CV" + """Returns true if the given value is a member of the CV""" return value in cls.string class Rate(CV): - """Options for ``data_rate`` + """Options for :attr:`data_rate` +-----------------------+------------------------------------------------------------------+ | Rate | Description | @@ -115,7 +116,32 @@ class Rate(CV): class HTS221: # pylint: disable=too-many-instance-attributes """Library for the ST HTS221 Humidity and Temperature Sensor - :param ~busio.I2C i2c_bus: The I2C bus the HTS221HB is connected to. + :param ~busio.I2C i2c_bus: The I2C bus the HTS221 is connected to + + + **Quickstart: Importing and using the HTS221** + + Here is an example of using the :class:`HTS221` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import adafruit_hts221 + + Once this is done you can define your `board.I2C` object and define your sensor object + + .. code-block:: python + + i2c = board.I2C() # uses board.SCL and board.SDA + hts = adafruit_hts221.HTS221(i2c) + + Now you have access to the :attr:`temperature` and :attr:`relative_humidity` attributes + + .. code-block:: python + + temperature = hts.temperature + relative_humidity = hts.relative_humidity """ @@ -203,7 +229,7 @@ def relative_humidity(self): @property def temperature(self): - """The current temperature measurement in degrees C""" + """The current temperature measurement in degrees Celsius""" calibrated_value_delta = self.calibrated_value_1 - self.calib_temp_value_0 calibrated_measurement_delta = self.calib_temp_meas_1 - self.calib_temp_meas_0 @@ -222,10 +248,11 @@ def temperature(self): @property def data_rate(self): - """The rate at which the sensor measures ``relative_humidity`` and ``temperature``. - ``data_rate`` should be set to one of the values of ``adafruit_hts221.Rate``. Note that - setting ``data_rate`` to ``Rate.ONE_SHOT`` will cause ``relative_humidity`` and - ``temperature`` measurements to only update when ``take_measurements`` is called.""" + """The rate at which the sensor measures :attr:`relative_humidity` and :attr:`temperature`. + :attr:`data_rate` should be set to one of the values of :class:`adafruit_hts221.Rate`. + Note that setting :attr:`data_rate` to ``Rate.ONE_SHOT`` will cause + :attr:`relative_humidity` and :attr:`temperature` measurements to only + update when :meth:`take_measurements` is called.""" return self._data_rate @data_rate.setter @@ -246,8 +273,8 @@ def temperature_data_ready(self): return self._temperature_status_bit def take_measurements(self): - """Update the value of ``relative_humidity`` and ``temperature`` by taking a single - measurement. Only meaningful if ``data_rate`` is set to ``ONE_SHOT``""" + """Update the value of :attr:`relative_humidity` and :attr:`temperature` by taking a single + measurement. Only meaningful if :attr:`data_rate` is set to ``ONE_SHOT``""" self._one_shot_bit = True while self._one_shot_bit: pass diff --git a/docs/api.rst b/docs/api.rst index e8ff00f..ce4c7b4 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -6,3 +6,4 @@ .. automodule:: adafruit_hts221 :members: + :exclude-members: CV diff --git a/docs/index.rst b/docs/index.rst index 289f99a..ef35ecb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,11 +23,12 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit HTS221 - Temperature & Humidity Sensor Learning Guide .. toctree:: :caption: Related Products - * `HTS221 Breakout `_ + Adafruit HTS221 - Temperature & Humidity Sensor Breakout Board .. toctree:: :caption: Other Links diff --git a/examples/hts221_simpletest.py b/examples/hts221_simpletest.py index bdb0020..2dd96d4 100644 --- a/examples/hts221_simpletest.py +++ b/examples/hts221_simpletest.py @@ -3,11 +3,11 @@ import time import board -import busio import adafruit_hts221 -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() hts = adafruit_hts221.HTS221(i2c) + while True: print("Relative Humidity: %.2f %% rH" % hts.relative_humidity) print("Temperature: %.2f C" % hts.temperature)