50
50
51
51
52
52
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
+ """
54
87
55
88
def __init__ (self , i2c_bus , ambient_pressure = 0 , address = SCD30_DEFAULT_ADDR ):
56
89
if ambient_pressure != 0 :
@@ -80,7 +113,10 @@ def reset(self):
80
113
def measurement_interval (self ):
81
114
"""Sets the interval between readings in seconds. The interval value must be from 2-1800
82
115
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
+ """
84
120
85
121
return self ._read_register (_CMD_SET_MEASUREMENT_INTERVAL )
86
122
@@ -96,10 +132,14 @@ def self_calibration_enabled(self):
96
132
be on and active for 7 days after enabling ASC, and exposed to fresh air for at least 1 hour
97
133
per day. Consult the manufacturer's documentation for more information.
98
134
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`.
101
141
102
- **NOTE** This setting will be saved and will not be reset on boot or by calling `reset`. """
142
+ """
103
143
104
144
return self ._read_register (_CMD_AUTOMATIC_SELF_CALIBRATION ) == 1
105
145
@@ -134,7 +174,11 @@ def altitude(self):
134
174
this value adjusts the CO2 measurement calculations to account for the air pressure's effect
135
175
on readings.
136
176
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
+ """
138
182
return self ._read_register (_CMD_SET_ALTITUDE_COMPENSATION )
139
183
140
184
@altitude .setter
@@ -147,7 +191,10 @@ def temperature_offset(self):
147
191
the measured signal. Value is in degrees Celsius with a resolution of 0.01 degrees and a
148
192
maximum value of 655.35 C
149
193
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
+ """
151
198
152
199
raw_offset = self ._read_register (_CMD_SET_TEMPERATURE_OFFSET )
153
200
return raw_offset / 100.0
@@ -156,7 +203,7 @@ def temperature_offset(self):
156
203
def temperature_offset (self , offset ):
157
204
if offset > 655.35 :
158
205
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 "
160
207
)
161
208
162
209
self ._send_command (_CMD_SET_TEMPERATURE_OFFSET , int (offset * 100 ))
@@ -166,8 +213,11 @@ def forced_recalibration_reference(self):
166
213
"""Specifies the concentration of a reference source of CO2 placed in close proximity to the
167
214
sensor. The value must be from 400 to 2000 ppm.
168
215
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
+ """
171
221
return self ._read_register (_CMD_SET_FORCED_RECALIBRATION_FACTOR )
172
222
173
223
@forced_recalibration_reference .setter
@@ -178,16 +228,22 @@ def forced_recalibration_reference(self, reference_value):
178
228
def CO2 (self ): # pylint:disable=invalid-name
179
229
"""Returns the CO2 concentration in PPM (parts per million)
180
230
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
+ """
182
235
if self .data_available :
183
236
self ._read_data ()
184
237
return self ._co2
185
238
186
239
@property
187
240
def temperature (self ):
188
- """Returns the current temperature in degrees celcius
241
+ """Returns the current temperature in degrees Celsius
189
242
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
+ """
191
247
if self .data_available :
192
248
self ._read_data ()
193
249
return self ._temperature
@@ -196,7 +252,10 @@ def temperature(self):
196
252
def relative_humidity (self ):
197
253
"""Returns the current relative humidity in %rH.
198
254
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
+ """
200
259
if self .data_available :
201
260
self ._read_data ()
202
261
return self ._relative_humidity
0 commit comments