Skip to content

Commit

Permalink
Merge pull request #17 from csylvain/patch-1
Browse files Browse the repository at this point in the history
using tsl.lux can produce unanticipated Exception
  • Loading branch information
tannewt authored Dec 6, 2018
2 parents 986ccdf + 0477930 commit 9535c8e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/tsl2561_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# Get raw (luminosity) readings using tuple unpacking
#broadband, infrared = tsl.luminosity

# Get computed lux value
# Get computed lux value (tsl.lux can return None or a float)
lux = tsl.lux

# Print results
Expand All @@ -43,7 +43,10 @@
print("Integration time = {}".format(tsl.integration_time))
print("Broadband = {}".format(broadband))
print("Infrared = {}".format(infrared))
print("Lux = {}".format(lux))
if lux is not None:
print("Lux = {}".format(lux))
else:
print("Lux value is None. Possible sensor underrange or overrange.")

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

0 comments on commit 9535c8e

Please sign in to comment.