Skip to content

Commit 9535c8e

Browse files
authored
Merge pull request #17 from csylvain/patch-1
using tsl.lux can produce unanticipated Exception
2 parents 986ccdf + 0477930 commit 9535c8e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/tsl2561_simpletest.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# Get raw (luminosity) readings using tuple unpacking
3535
#broadband, infrared = tsl.luminosity
3636

37-
# Get computed lux value
37+
# Get computed lux value (tsl.lux can return None or a float)
3838
lux = tsl.lux
3939

4040
# Print results
@@ -43,7 +43,10 @@
4343
print("Integration time = {}".format(tsl.integration_time))
4444
print("Broadband = {}".format(broadband))
4545
print("Infrared = {}".format(infrared))
46-
print("Lux = {}".format(lux))
46+
if lux is not None:
47+
print("Lux = {}".format(lux))
48+
else:
49+
print("Lux value is None. Possible sensor underrange or overrange.")
4750

4851
# Disble the light sensor (to save power)
4952
tsl.enabled = False

0 commit comments

Comments
 (0)