Skip to content

Commit 5f2ac47

Browse files
authored
Merge pull request #4 from jposada202020/improving_docs
Changing in function docs
2 parents 03f9485 + 7a926b6 commit 5f2ac47

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

adafruit_sht4x.py

+41-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
1616
**Hardware:**
1717
18-
Python library for Sensirion SHT4x temperature and humidity sensors
18+
* Adafruit's SHT40 Temperature & Humidity Sensor: https://www.adafruit.com/product/4885
1919
2020
**Software and Dependencies:**
2121
2222
* Adafruit CircuitPython firmware for the supported boards:
23-
https://github.com/adafruit/circuitpython/releases
23+
https://circuitpython.org/downloads
2424
2525
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2626
@@ -86,7 +86,42 @@ class SHT4x:
8686
"""
8787
A driver for the SHT4x temperature and humidity sensor.
8888
89-
:param ~busio.I2C i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
89+
:param ~busio.I2C i2c_bus: The `busio.I2C` object to use.
90+
:param int address: The I2C device address for the sensor. Default is :const:`0x44`
91+
92+
93+
**Quickstart: Importing and using the SHT4x temperature and humidity sensor**
94+
95+
Here is one way of importing the `SHT4x` class so you can use it with the name ``sht``.
96+
First you will need to import the libraries to use the sensor
97+
98+
.. code-block:: python
99+
100+
import busio
101+
import board
102+
import adafruit_sht4x
103+
104+
Once this is done you can define your `busio.I2C` object and define your sensor object
105+
106+
.. code-block:: python
107+
108+
i2c = busio.I2C(board.SCL, board.SDA)
109+
sht = adafruit_sht4x.SHT4x(i2c)
110+
111+
You can now make some initial settings on the sensor
112+
113+
.. code-block:: python
114+
115+
sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION
116+
117+
Now you have access to the temperature and humidity using the :attr:`measurements`.
118+
It will return a tuple with the :attr:`temperature` and :attr:`relative_humidity`
119+
measurements
120+
121+
122+
.. code-block:: python
123+
124+
temperature, relative_humidity = sht.measurements
90125
91126
"""
92127

@@ -138,12 +173,12 @@ def mode(self, new_mode):
138173

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

144179
@property
145180
def temperature(self):
146-
"""The current temperature in degrees celsius"""
181+
"""The current temperature in degrees Celsius"""
147182
return self.measurements[0]
148183

149184
@property
@@ -191,6 +226,7 @@ def measurements(self):
191226

192227
@staticmethod
193228
def _crc8(buffer):
229+
"""verify the crc8 checksum"""
194230
crc = 0xFF
195231
for byte in buffer:
196232
crc ^= byte

0 commit comments

Comments
 (0)