Skip to content

Commit c6c7078

Browse files
authored
Merge pull request #15 from jposada202020/improving_docs
improving docs, adding .idea to gitignore
2 parents 0b0b648 + 373286b commit c6c7078

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ _build
77
*.pyc
88
.env
99
bundles
10+
.idea

adafruit_htu21d.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
`adafruit_htu21d`
77
====================================================
88
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
1011
1112
* Author(s): ktown
1213
@@ -61,9 +62,38 @@ def _crc(data):
6162
class HTU21D:
6263
"""
6364
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+
6797
"""
6898

6999
def __init__(self, i2c_bus, address=0x40):
@@ -102,7 +132,7 @@ def relative_humidity(self):
102132

103133
@property
104134
def temperature(self):
105-
"""The measured temperature in degrees Celcius."""
135+
"""The measured temperature in degrees Celsius."""
106136
self.measurement(TEMPERATURE)
107137
self._measurement = 0
108138
time.sleep(0.050)
@@ -114,7 +144,7 @@ def measurement(self, what):
114144
Starts a measurement of either ``HUMIDITY`` or ``TEMPERATURE``
115145
depending on the ``what`` argument. Returns immediately, and the
116146
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
118148
will take much less time.
119149
This can be useful if you want to start the measurement, but don't
120150
want the call to block until the measurement is ready -- for instance,

0 commit comments

Comments
 (0)