Skip to content

Commit 3790550

Browse files
Merge pull request #21 from jposada202020/improving_gain_error_code
Adding message when gain overflows the sensor
2 parents 70334fe + c5fd5d5 commit 3790550

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adafruit_tsl2591.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ def lux(self):
244244

245245
# Handle overflow.
246246
if channel_0 >= max_counts or channel_1 >= max_counts:
247-
raise RuntimeError("Overflow reading light channels!")
247+
message = (
248+
"Overflow reading light channels!, Try to reduce the gain of\n "
249+
+ "the sensor using adafruit_tsl2591.GAIN_LOW"
250+
)
251+
raise RuntimeError(message)
248252
# Calculate lux using same equation as Arduino library:
249253
# https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp
250254
again = 1.0

0 commit comments

Comments
 (0)