@@ -229,11 +229,29 @@ def stop_periodic_measurement(self):
229
229
self ._send_command (_SCD4X_STOPPERIODICMEASUREMENT , cmd_delay = 0.5 )
230
230
231
231
def start_periodic_measurement (self ):
232
- """Put sensor into working mode, about 5s per measurement"""
232
+ """Put sensor into working mode, about 5s per measurement
233
+
234
+ .. note::
235
+ Only the following commands will work once in working mode:
236
+
237
+ * :attr:`CO2 <adafruit_scd4x.SCD4X.CO2>`
238
+ * :attr:`temperature <adafruit_scd4x.SCD4X.temperature>`
239
+ * :attr:`relative_humidity <adafruit_scd4x.SCD4X.relative_humidity>`
240
+ * :meth:`data_ready() <adafruit_scd4x.SCD4x.data_ready>`
241
+ * :meth:`reinit() <adafruit_scd4x.SCD4X.reinit>`
242
+ * :meth:`factory_reset() <adafruit_scd4x.SCD4X.factory_reset>`
243
+ * :meth:`force_calibration() <adafruit_scd4x.SCD4X.force_calibration>`
244
+ * :meth:`self_test() <adafruit_scd4x.SCD4X.self_test>`
245
+ * :meth:`set_ambient_pressure() <adafruit_scd4x.SCD4X.set_ambient_pressure>`
246
+
247
+ """
233
248
self ._send_command (_SCD4X_STARTPERIODICMEASUREMENT )
234
249
235
250
def start_low_periodic_measurement (self ):
236
- """Put sensor into low power working mode, about 30s per measurement"""
251
+ """Put sensor into low power working mode, about 30s per measurement. See
252
+ :meth:`start_periodic_measurement() <adafruit_scd4x.SCD4X.start_perodic_measurement>`
253
+ for more details.
254
+ """
237
255
self ._send_command (_SCD4X_STARTLOWPOWERPERIODICMEASUREMENT )
238
256
239
257
def persist_settings (self ):
@@ -303,8 +321,14 @@ def _send_command(self, cmd: int, cmd_delay: float = 0) -> None:
303
321
self ._cmd [0 ] = (cmd >> 8 ) & 0xFF
304
322
self ._cmd [1 ] = cmd & 0xFF
305
323
306
- with self .i2c_device as i2c :
307
- i2c .write (self ._cmd , end = 2 )
324
+ try :
325
+ with self .i2c_device as i2c :
326
+ i2c .write (self ._cmd , end = 2 )
327
+ except OSError as err :
328
+ raise RuntimeError (
329
+ "Could not communicate via I2C, some commands/settings "
330
+ "unavailable while in working mode"
331
+ ) from err
308
332
time .sleep (cmd_delay )
309
333
310
334
def _set_command_value (self , cmd , value , cmd_delay = 0 ):
0 commit comments