Skip to content

Changing in function docs #4

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 1 commit into from
Apr 14, 2021
Merged
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
46 changes: 41 additions & 5 deletions adafruit_sht4x.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

**Hardware:**

Python library for Sensirion SHT4x temperature and humidity sensors
* Adafruit's SHT40 Temperature & Humidity Sensor: https://www.adafruit.com/product/4885

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
https://circuitpython.org/downloads

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

Expand Down Expand Up @@ -86,7 +86,42 @@ class SHT4x:
"""
A driver for the SHT4x 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 `busio.I2C` object to use.
:param int address: The I2C device address for the sensor. Default is :const:`0x44`


**Quickstart: Importing and using the SHT4x temperature and humidity sensor**

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

.. code-block:: python

import busio
import board
import adafruit_sht4x

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)
sht = adafruit_sht4x.SHT4x(i2c)

You can now make some initial settings on the sensor

.. code-block:: python

sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION

Now you have access to the temperature and humidity using the :attr:`measurements`.
It will return a tuple with the :attr:`temperature` and :attr:`relative_humidity`
measurements


.. code-block:: python

temperature, relative_humidity = sht.measurements

"""

Expand Down Expand Up @@ -138,12 +173,12 @@ def mode(self, new_mode):

@property
def relative_humidity(self):
"""The current relative humidity in % rH"""
"""The current relative humidity in % rH. This is a value from 0-100%."""
return self.measurements[1]

@property
def temperature(self):
"""The current temperature in degrees celsius"""
"""The current temperature in degrees Celsius"""
return self.measurements[0]

@property
Expand Down Expand Up @@ -191,6 +226,7 @@ def measurements(self):

@staticmethod
def _crc8(buffer):
"""verify the crc8 checksum"""
crc = 0xFF
for byte in buffer:
crc ^= byte
Expand Down