Skip to content

Commit 5e9a8f2

Browse files
committed
example
1 parent 1142f5c commit 5e9a8f2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,28 @@ To install in a virtual environment in your current project:
5959
Usage Example
6060
=============
6161

62-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
62+
.. code-block:: python
63+
64+
import time
65+
import busio
66+
import board
67+
import adafruit_htu31d
68+
69+
i2c = busio.I2C(board.SCL, board.SDA)
70+
htu = adafruit_htu31d.HTU31D(i2c)
71+
print("Found HTU31D with serial number", hex(htu.serial_number))
72+
73+
htu.heater = True
74+
print("Heater is on?", htu.heater)
75+
htu.heater = False
76+
print("Heater is on?", htu.heater)
77+
78+
while True:
79+
temperature, relative_humidity = htu.measurements
80+
print("Temperature: %0.1f C" % temperature)
81+
print("Humidity: %0.1f %%" % relative_humidity)
82+
print("")
83+
time.sleep(1)
6384
6485
Contributing
6586
============

0 commit comments

Comments
 (0)