Skip to content

Commit 0d9b68d

Browse files
authored
Merge pull request #3 from brentru/autodoc-fix
Fix autodoc + Usage Notes
2 parents faa115b + 533ccd8 commit 0d9b68d

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

README.rst

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,42 @@ Please ensure all dependencies are available on the CircuitPython filesystem.
2323
This is easily achieved by downloading
2424
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
2525

26-
Usage Example
26+
Usage Notes
2727
=============
2828

29-
TODO
29+
See `the guide <https://learn.adafruit.com/adafruit-sgp30-gas-tvoc-eco2-mox-sensor/circuitpython-wiring-test>`_
30+
for wiring and installation instructions.
31+
32+
First, import the library:
33+
34+
.. code-block:: python
35+
36+
import busio
37+
import adafruit_sgp30
38+
39+
Next, initialize the I2C bus object:
40+
41+
.. code-block:: python
42+
43+
from board import *
44+
i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=100000)
45+
46+
Since we have the I2C bus object, we can now use it to instantiate the SGP30 object:
47+
48+
.. code-block:: python
49+
50+
sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus)
51+
52+
Reading from the Sensor
53+
--------------
54+
55+
To read from the sensor:
56+
57+
.. code-block:: python
58+
59+
co2eq, tvoc = sgp30.iaq_measure()
60+
print("CO2eq = %d ppm \t TVOC = %d ppb" % (co2eq, tvoc))
61+
3062
3163
API Reference
3264
=============

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Uncomment the below if you use native CircuitPython modules such as
1919
# digitalio, micropython and busio. List the modules you use. Without it, the
2020
# autodoc module docs will fail to generate with a warning.
21-
# autodoc_mock_imports = ["digitalio", "busio"]
21+
autodoc_mock_imports = ["adafruit_bus_device", "micropython"]
2222

2323
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
2424

0 commit comments

Comments
 (0)