Skip to content

Commit f32d6f1

Browse files
committed
add readme test
1 parent 058cb8d commit f32d6f1

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,26 @@ Or the following command to update an existing version:
9999
Usage Example
100100
=============
101101

102-
.. todo:: Add a quick, simple example. It and other examples should live in the
103-
examples folder and be included in docs/examples.rst.
102+
.. code-block:: python
103+
104+
import time
105+
import board
106+
import adafruit_scd4x
107+
108+
i2c = board.I2C()
109+
scd4x = adafruit_scd4x.SCD4X(i2c)
110+
print("Serial number:", [hex(i) for i in scd4x.serial_number])
111+
112+
scd4x.start_periodic_measurement()
113+
print("Waiting for first measurement....")
114+
115+
while True:
116+
if scd4x.data_ready:
117+
print("CO2: %d ppm" % scd4x.CO2)
118+
print("Temperature: %0.1f *C" % scd4x.temperature)
119+
print("Humidity: %0.1f %%" % scd4x.relative_humidity)
120+
print()
121+
time.sleep(1)
104122
105123
Contributing
106124
============

0 commit comments

Comments
 (0)