Skip to content

Commit 1e44b67

Browse files
committed
retry logic for initial enabling of device from light_shutdown
1 parent dc1e921 commit 1e44b67

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

adafruit_veml7700.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,15 @@ class VEML7700:
186186

187187
def __init__(self, i2c_bus, address=0x10):
188188
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
189-
self.light_shutdown = False # Enable the ambient light sensor
189+
for _ in range(3):
190+
try:
191+
self.light_shutdown = False # Enable the ambient light sensor
192+
break
193+
except OSError:
194+
pass
195+
else:
196+
raise RuntimeError("Unable to enable VEML7700 device")
197+
190198

191199
def integration_time_value(self):
192200
"""Integration time value in integer form. Used for calculating ``resolution``."""

0 commit comments

Comments
 (0)