|
15 | 15 |
|
16 | 16 | **Hardware:**
|
17 | 17 |
|
18 |
| -Python library for Sensirion SHT4x temperature and humidity sensors |
| 18 | +* Adafruit's SHT40 Temperature & Humidity Sensor: https://www.adafruit.com/product/4885 |
19 | 19 |
|
20 | 20 | **Software and Dependencies:**
|
21 | 21 |
|
22 | 22 | * Adafruit CircuitPython firmware for the supported boards:
|
23 |
| - https://github.com/adafruit/circuitpython/releases |
| 23 | + https://circuitpython.org/downloads |
24 | 24 |
|
25 | 25 | * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
26 | 26 |
|
@@ -86,7 +86,42 @@ class SHT4x:
|
86 | 86 | """
|
87 | 87 | A driver for the SHT4x temperature and humidity sensor.
|
88 | 88 |
|
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 |
90 | 125 |
|
91 | 126 | """
|
92 | 127 |
|
@@ -138,12 +173,12 @@ def mode(self, new_mode):
|
138 | 173 |
|
139 | 174 | @property
|
140 | 175 | 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%.""" |
142 | 177 | return self.measurements[1]
|
143 | 178 |
|
144 | 179 | @property
|
145 | 180 | def temperature(self):
|
146 |
| - """The current temperature in degrees celsius""" |
| 181 | + """The current temperature in degrees Celsius""" |
147 | 182 | return self.measurements[0]
|
148 | 183 |
|
149 | 184 | @property
|
@@ -191,6 +226,7 @@ def measurements(self):
|
191 | 226 |
|
192 | 227 | @staticmethod
|
193 | 228 | def _crc8(buffer):
|
| 229 | + """verify the crc8 checksum""" |
194 | 230 | crc = 0xFF
|
195 | 231 | for byte in buffer:
|
196 | 232 | crc ^= byte
|
|
0 commit comments