Skip to content

Commit 927e91a

Browse files
committed
update reset
1 parent b470c62 commit 927e91a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

adafruit_ltr390.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,16 @@ def initialize(self):
304304
# ltr.configInterrupt(true, LTR390_MODE_UVS);
305305

306306
def _reset(self):
307-
try:
308-
self._reset_bit = True
309-
except OSError:
310-
# The write to the reset bit will fail because it seems to not ACK before it resets
311-
pass
312-
313-
sleep(0.1)
314-
# check that reset is complete w/ the bit unset
315-
if self._reset_bit:
316-
raise RuntimeError("Unable to reset sensor")
307+
# The LTR390 software reset is ill behaved and can leave I2C bus in bad state.
308+
# Instead, just manually set register reset values per datasheet.
309+
with self.i2c_device as i2c:
310+
i2c.write(bytes([_CTRL, 0x00]))
311+
i2c.write(bytes([_MEAS_RATE, 0x22]))
312+
i2c.write(bytes([_GAIN, 0x01]))
313+
i2c.write(bytes([_INT_CFG, 0x10]))
314+
i2c.write(bytes([_INT_PST, 0x00]))
315+
i2c.write(bytes([_THRESH_UP, 0xFF, 0xFF, 0x0F]))
316+
i2c.write(bytes([_THRESH_LOW, 0x00, 0x00, 0x00]))
317317

318318
@property
319319
def _mode(self):

0 commit comments

Comments
 (0)