66`adafruit_shtc3`
77================================================================================
88
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
1010
1111
1212* Author(s): Bryan Siepert
1616
1717**Hardware:**
1818
19- * Adafruit's ICM20649 Breakout : https://www.adafruit.com/product/4636
19+ * Adafruit's SHTC3 Temperature & Humidity Sensor : https://www.adafruit.com/product/4636
2020
2121**Software and Dependencies:**
2222
@@ -83,6 +83,32 @@ class SHTC3:
8383
8484 :param ~busio.I2C i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
8585
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+
86112 """
87113
88114 def __init__ (self , i2c_bus ):
@@ -93,9 +119,10 @@ def __init__(self, i2c_bus):
93119 self .sleeping = False
94120 self .reset ()
95121 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!" )
97123
98124 def _write_command (self , command ):
125+ """helper function to write a command to the i2c device"""
99126 self ._buffer [0 ] = command >> 8
100127 self ._buffer [1 ] = command & 0xFF
101128
@@ -104,6 +131,7 @@ def _write_command(self, command):
104131
105132 @property
106133 def _chip_id (self ): # readCommand(SHTC3_READID, data, 3);
134+ """Determines the chip id of the sensor"""
107135 self ._buffer [0 ] = _SHTC3_READID >> 8
108136 self ._buffer [1 ] = _SHTC3_READID & 0xFF
109137
@@ -152,12 +180,12 @@ def low_power(self, low_power_enabled):
152180
153181 @property
154182 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%. """
156184 return self .measurements [1 ]
157185
158186 @property
159187 def temperature (self ):
160- """The current temperature in degrees celcius """
188+ """The current temperature in degrees Celsius """
161189 return self .measurements [0 ]
162190
163191 @property
@@ -213,6 +241,7 @@ def measurements(self):
213241
214242 @staticmethod
215243 def _crc8 (buffer ):
244+ """verify the crc8 checksum"""
216245 crc = 0xFF
217246 for byte in buffer :
218247 crc ^= byte
0 commit comments