Skip to content

Commit 54ef552

Browse files
committed
Improving Docs
1 parent 5f0ba95 commit 54ef552

7 files changed

+88
-24
lines changed

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ Usage Example
6464
6565
import time
6666
import board
67-
import busio
6867
import adafruit_scd30
6968
70-
i2c = busio.I2C(board.SCL, board.SDA)
69+
i2c = board.I2C() # uses board.SCL and board.SDA
7170
scd = adafruit_scd30.SCD30(i2c)
7271
7372
while True:

adafruit_scd30.py

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,40 @@
5050

5151

5252
class SCD30:
53-
"""CircuitPython helper class for using the SCD30 CO2 sensor"""
53+
"""
54+
CircuitPython helper class for using the SCD30 CO2 sensor
55+
56+
:param ~busio.I2C i2c_bus: The I2C bus the SCD30 is connected to.
57+
:param int ambient_pressure: Ambient pressure compensation. Defaults to :const:`0`
58+
:param int address: The I2C device address for the sensor. Default is :const:`0x61`
59+
60+
**Quickstart: Importing and using the SCD30**
61+
62+
Here is an example of using the :class:`SCD30` class.
63+
First you will need to import the libraries to use the sensor
64+
65+
.. code-block:: python
66+
67+
import board
68+
import adafruit_scd30
69+
70+
Once this is done you can define your `board.I2C` object and define your sensor object
71+
72+
.. code-block:: python
73+
74+
i2c = board.I2C() # uses board.SCL and board.SDA
75+
scd = adafruit_scd30.SCD30(i2c)
76+
77+
Now you have access to the CO2, temperature and humidity using
78+
the :attr:`CO2`, :attr:`temperature` and :attr:`relative_humidity` attributes
79+
80+
.. code-block:: python
81+
82+
temperature = scd.temperature
83+
relative_humidity = scd.relative_humidity
84+
co2_ppm_level = scd.CO2
85+
86+
"""
5487

5588
def __init__(self, i2c_bus, ambient_pressure=0, address=SCD30_DEFAULT_ADDR):
5689
if ambient_pressure != 0:
@@ -80,7 +113,10 @@ def reset(self):
80113
def measurement_interval(self):
81114
"""Sets the interval between readings in seconds. The interval value must be from 2-1800
82115
83-
**NOTE** This value will be saved and will not be reset on boot or by calling `reset`."""
116+
.. note::
117+
This value will be saved and will not be reset on boot or by calling `reset`.
118+
119+
"""
84120

85121
return self._read_register(_CMD_SET_MEASUREMENT_INTERVAL)
86122

@@ -96,10 +132,14 @@ def self_calibration_enabled(self):
96132
be on and active for 7 days after enabling ASC, and exposed to fresh air for at least 1 hour
97133
per day. Consult the manufacturer's documentation for more information.
98134
99-
**NOTE**: Enabling self calibration will override any values set by specifying a
100-
`forced_recalibration_reference`
135+
.. note::
136+
Enabling self calibration will override any values set by specifying a
137+
`forced_recalibration_reference`
138+
139+
.. note::
140+
This value will be saved and will not be reset on boot or by calling `reset`.
101141
102-
**NOTE** This setting will be saved and will not be reset on boot or by calling `reset`."""
142+
"""
103143

104144
return self._read_register(_CMD_AUTOMATIC_SELF_CALIBRATION) == 1
105145

@@ -134,7 +174,11 @@ def altitude(self):
134174
this value adjusts the CO2 measurement calculations to account for the air pressure's effect
135175
on readings.
136176
137-
**NOTE** This value will be stored and will not be reset on boot or by calling `reset`."""
177+
.. note::
178+
This value will be saved and will not be reset on boot or by calling `reset`.
179+
180+
181+
"""
138182
return self._read_register(_CMD_SET_ALTITUDE_COMPENSATION)
139183

140184
@altitude.setter
@@ -147,7 +191,10 @@ def temperature_offset(self):
147191
the measured signal. Value is in degrees Celsius with a resolution of 0.01 degrees and a
148192
maximum value of 655.35 C
149193
150-
**NOTE** This value will be saved and will not be reset on boot or by calling `reset`."""
194+
.. note::
195+
This value will be saved and will not be reset on boot or by calling `reset`.
196+
197+
"""
151198

152199
raw_offset = self._read_register(_CMD_SET_TEMPERATURE_OFFSET)
153200
return raw_offset / 100.0
@@ -156,7 +203,7 @@ def temperature_offset(self):
156203
def temperature_offset(self, offset):
157204
if offset > 655.35:
158205
raise AttributeError(
159-
"Offset value must be less than or equal to 655.35 degrees Celcius"
206+
"Offset value must be less than or equal to 655.35 degrees Celsius"
160207
)
161208

162209
self._send_command(_CMD_SET_TEMPERATURE_OFFSET, int(offset * 100))
@@ -166,8 +213,11 @@ def forced_recalibration_reference(self):
166213
"""Specifies the concentration of a reference source of CO2 placed in close proximity to the
167214
sensor. The value must be from 400 to 2000 ppm.
168215
169-
**NOTE**: Specifying a forced recalibration reference will override any calibration values
170-
set by Automatic Self Calibration"""
216+
.. note::
217+
Specifying a forced recalibration reference will override any calibration values
218+
set by Automatic Self Calibration
219+
220+
"""
171221
return self._read_register(_CMD_SET_FORCED_RECALIBRATION_FACTOR)
172222

173223
@forced_recalibration_reference.setter
@@ -178,16 +228,22 @@ def forced_recalibration_reference(self, reference_value):
178228
def CO2(self): # pylint:disable=invalid-name
179229
"""Returns the CO2 concentration in PPM (parts per million)
180230
181-
**NOTE** Between measurements, the most recent reading will be cached and returned."""
231+
.. note::
232+
Between measurements, the most recent reading will be cached and returned.
233+
234+
"""
182235
if self.data_available:
183236
self._read_data()
184237
return self._co2
185238

186239
@property
187240
def temperature(self):
188-
"""Returns the current temperature in degrees celcius
241+
"""Returns the current temperature in degrees Celsius
189242
190-
**NOTE** Between measurements, the most recent reading will be cached and returned."""
243+
.. note::
244+
Between measurements, the most recent reading will be cached and returned.
245+
246+
"""
191247
if self.data_available:
192248
self._read_data()
193249
return self._temperature
@@ -196,7 +252,10 @@ def temperature(self):
196252
def relative_humidity(self):
197253
"""Returns the current relative humidity in %rH.
198254
199-
**NOTE** Between measurements, the most recent reading will be cached and returned."""
255+
.. note::
256+
Between measurements, the most recent reading will be cached and returned.
257+
258+
"""
200259
if self.data_available:
201260
self._read_data()
202261
return self._relative_humidity

docs/examples.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ Experiment with different tuning parameters and settings
1515
.. literalinclude:: ../examples/scd30_tuning_knobs.py
1616
:caption: examples/scd30_tuning_knobs.py
1717
:linenos:
18+
19+
MCP2221 and SCD30 Example
20+
-------------------------
21+
22+
MCP2221 is known to not like the SCD30. Here is how to avoid this!
23+
24+
.. literalinclude:: ../examples/scd30_tuning_knobs.py
25+
:caption: examples/scd30_tuning_knobs.py
26+
:linenos:

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit SCD30 Breakout Learning Guide <https://learn.adafruit.com/adafruit-scd30>
2627

2728
.. toctree::
2829
:caption: Related Products
2930

30-
31-
* Adafruit SCD30 Breakout <https://www.adafruit.com/product/48xx>`_
31+
Adafruit SCD30 Breakout <https://www.adafruit.com/product/4867>
3232

3333
.. toctree::
3434
:caption: Other Links

examples/scd30_mcp2221test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
# SPDX-License-Identifier: Unlicense
44
import time
55
import board
6-
import busio
76
import adafruit_scd30
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
109
scd = adafruit_scd30.SCD30(i2c)
1110

1211
# The SCD30 reset generates a hiccup on the SCL and SDA lines

examples/scd30_simpletest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
# SPDX-License-Identifier: Unlicense
44
import time
55
import board
6-
import busio
76
import adafruit_scd30
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
109
scd = adafruit_scd30.SCD30(i2c)
1110

1211
while True:

examples/scd30_tuning_knobs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
# SPDX-License-Identifier: Unlicense
44
import time
55
import board
6-
import busio
76
import adafruit_scd30
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
109
scd = adafruit_scd30.SCD30(i2c)
1110
# scd.temperature_offset = 10
1211
print("Temperature offset:", scd.temperature_offset)

0 commit comments

Comments
 (0)