6
6
`adafruit_shtc3`
7
7
================================================================================
8
8
9
- A helper library for using the Senserion SHTC3 Humidity and Temperature Sensor
9
+ A helper library for using the Sensirion SHTC3 Humidity and Temperature Sensor
10
10
11
11
12
12
* Author(s): Bryan Siepert
16
16
17
17
**Hardware:**
18
18
19
- * Adafruit's ICM20649 Breakout : https://www.adafruit.com/product/4636
19
+ * Adafruit's SHTC3 Temperature & Humidity Sensor : https://www.adafruit.com/product/4636
20
20
21
21
**Software and Dependencies:**
22
22
@@ -83,6 +83,32 @@ class SHTC3:
83
83
84
84
:param ~busio.I2C i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
85
85
86
+ **Quickstart: Importing and using the SHTC3 temperature and humidity sensor**
87
+
88
+ Here is one way of importing the `SHTC3` class so you can use it with the name ``sht``.
89
+ First you will need to import the helper libraries to use the sensor
90
+
91
+ .. code-block:: python
92
+
93
+ import busio
94
+ import board
95
+ import adafruit_shtc3
96
+
97
+ Once this is done, you can define your `busio.I2C` object and define your sensor
98
+
99
+ .. code-block:: python
100
+
101
+ i2c = busio.I2C(board.SCL, board.SDA)
102
+ sht = adafruit_shtc3.SHTC3(i2c)
103
+
104
+ Now you have access to the temperature and humidity using the :attr:`measurements`.
105
+ it will return a tuple with the :attr:`temperature` and :attr:`relative_humidity`
106
+ measurements
107
+
108
+ .. code-block:: python
109
+
110
+ temperature, relative_humidity = sht.measurements
111
+
86
112
"""
87
113
88
114
def __init__ (self , i2c_bus ):
@@ -93,9 +119,10 @@ def __init__(self, i2c_bus):
93
119
self .sleeping = False
94
120
self .reset ()
95
121
if self ._chip_id & 0x083F != _SHTC3_CHIP_ID :
96
- raise RuntimeError ("Failed to find an ICM20X sensor - check your wiring!" )
122
+ raise RuntimeError ("Failed to find an SHTC3 sensor - check your wiring!" )
97
123
98
124
def _write_command (self , command ):
125
+ """helper function to write a command to the i2c device"""
99
126
self ._buffer [0 ] = command >> 8
100
127
self ._buffer [1 ] = command & 0xFF
101
128
@@ -104,6 +131,7 @@ def _write_command(self, command):
104
131
105
132
@property
106
133
def _chip_id (self ): # readCommand(SHTC3_READID, data, 3);
134
+ """Determines the chip id of the sensor"""
107
135
self ._buffer [0 ] = _SHTC3_READID >> 8
108
136
self ._buffer [1 ] = _SHTC3_READID & 0xFF
109
137
@@ -152,12 +180,12 @@ def low_power(self, low_power_enabled):
152
180
153
181
@property
154
182
def relative_humidity (self ):
155
- """The current relative humidity in % rH"""
183
+ """The current relative humidity in % rH. This is a value from 0-100%. """
156
184
return self .measurements [1 ]
157
185
158
186
@property
159
187
def temperature (self ):
160
- """The current temperature in degrees celcius """
188
+ """The current temperature in degrees Celsius """
161
189
return self .measurements [0 ]
162
190
163
191
@property
@@ -213,6 +241,7 @@ def measurements(self):
213
241
214
242
@staticmethod
215
243
def _crc8 (buffer ):
244
+ """verify the crc8 checksum"""
216
245
crc = 0xFF
217
246
for byte in buffer :
218
247
crc ^= byte
0 commit comments