|
28 | 28 | """
|
29 | 29 |
|
30 | 30 | # imports
|
31 |
| -from time import sleep |
| 31 | +import time |
32 | 32 | from struct import unpack_from, unpack
|
33 | 33 | import adafruit_bus_device.i2c_device as i2c_device
|
34 | 34 | from micropython import const
|
@@ -107,7 +107,7 @@ def __init__(self, i2c_bus, ambient_pressure=0, address=SCD30_DEFAULT_ADDR):
|
107 | 107 | def reset(self):
|
108 | 108 | """Perform a soft reset on the sensor, restoring default values"""
|
109 | 109 | self._send_command(_CMD_SOFT_RESET)
|
110 |
| - sleep(0.1) # not mentioned by datasheet, but required to avoid IO error |
| 110 | + time.sleep(0.1) # not mentioned by datasheet, but required to avoid IO error |
111 | 111 |
|
112 | 112 | @property
|
113 | 113 | def measurement_interval(self):
|
@@ -147,7 +147,7 @@ def self_calibration_enabled(self):
|
147 | 147 | def self_calibration_enabled(self, enabled):
|
148 | 148 | self._send_command(_CMD_AUTOMATIC_SELF_CALIBRATION, enabled)
|
149 | 149 | if enabled:
|
150 |
| - sleep(0.01) |
| 150 | + time.sleep(0.01) |
151 | 151 |
|
152 | 152 | @property
|
153 | 153 | def data_available(self):
|
@@ -278,13 +278,15 @@ def _send_command(self, command, arguments=None):
|
278 | 278 |
|
279 | 279 | with self.i2c_device as i2c:
|
280 | 280 | i2c.write(self._buffer, end=end_byte)
|
| 281 | + time.sleep(0.05) # 3ms min delay |
281 | 282 |
|
282 | 283 | def _read_register(self, reg_addr):
|
283 | 284 | self._buffer[0] = reg_addr >> 8
|
284 | 285 | self._buffer[1] = reg_addr & 0xFF
|
285 | 286 | with self.i2c_device as i2c:
|
286 | 287 | i2c.write(self._buffer, end=2)
|
287 | 288 | # separate readinto because the SCD30 wants an i2c stop before the read (non-repeated start)
|
| 289 | + time.sleep(0.005) # min 3 ms delay |
288 | 290 | with self.i2c_device as i2c:
|
289 | 291 | i2c.readinto(self._buffer, end=2)
|
290 | 292 | return unpack_from(">H", self._buffer)[0]
|
|
0 commit comments