6
6
`adafruit_htu21d`
7
7
====================================================
8
8
9
- This is a breakout for the Adafruit HTU21D-F humidity sensor breakout.
9
+ This is a breakout for the Adafruit HTU21D-F Temperature & Humidity
10
+ Sensor Breakout Board
10
11
11
12
* Author(s): ktown
12
13
@@ -61,9 +62,38 @@ def _crc(data):
61
62
class HTU21D :
62
63
"""
63
64
A driver for the HTU21D-F temperature and humidity sensor.
64
- :param i2c_bus: The `busio.I2C` object to use. This is the only
65
- required parameter.
66
- :param int address: (optional) The I2C address of the device.
65
+
66
+ :param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
67
+ :param int address: (optional) The I2C address of the device. Defaults to :const:`0x40`
68
+
69
+
70
+ **Quickstart: Importing and using the HTU21D temperature sensor**
71
+
72
+ Here is one way of importing the `HTU21D` class so you can use it with the name ``htu``.
73
+ First you will need to import the libraries to use the sensor
74
+
75
+ .. code-block:: python
76
+
77
+ import busio
78
+ import board
79
+ import adafruit_htu21d
80
+
81
+ Once this is done you can define your `busio.I2C` object and define your sensor object
82
+
83
+ .. code-block:: python
84
+
85
+ i2c = busio.I2C(board.SCL, board.SDA)
86
+ htu = adafruit_htu21d.HTU21D(i2c)
87
+
88
+ Now you have access to the temperature and humidity using
89
+ the :attr:`temperature` and :attr:`relative_humidity` attributes
90
+
91
+ .. code-block:: python
92
+
93
+ temperature = htu.temperature
94
+ relative_humidity = htu.relative_humidity
95
+
96
+
67
97
"""
68
98
69
99
def __init__ (self , i2c_bus , address = 0x40 ):
@@ -102,7 +132,7 @@ def relative_humidity(self):
102
132
103
133
@property
104
134
def temperature (self ):
105
- """The measured temperature in degrees Celcius ."""
135
+ """The measured temperature in degrees Celsius ."""
106
136
self .measurement (TEMPERATURE )
107
137
self ._measurement = 0
108
138
time .sleep (0.050 )
@@ -114,7 +144,7 @@ def measurement(self, what):
114
144
Starts a measurement of either ``HUMIDITY`` or ``TEMPERATURE``
115
145
depending on the ``what`` argument. Returns immediately, and the
116
146
result of the measurement can be retrieved with the
117
- `` temperature`` and `` relative_humidity` ` properties. This way it
147
+ :attr:` temperature` and :attr:` relative_humidity` properties. This way it
118
148
will take much less time.
119
149
This can be useful if you want to start the measurement, but don't
120
150
want the call to block until the measurement is ready -- for instance,
0 commit comments