Skip to content

revise lux calculation to accept 0 reading without error #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions adafruit_tsl2561.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ def _compute_lux(self):
if ch1 > _CLIP_THRESHOLD[self.integration_time]:
return None
ratio = ch1 / ch0
if ratio > 0 and ratio <= 0.50:
if ratio >= 0 and ratio <= 0.50:
lux = 0.0304 * ch0 - 0.062 * ch0 * ratio**1.4
elif ratio > 0.50 and ratio <= 0.61:
elif ratio <= 0.61:
lux = 0.0224 * ch0 - 0.031 * ch1
elif ratio > 0.61 and ratio <= 0.80:
elif ratio <= 0.80:
lux = 0.0128 * ch0 - 0.0153 * ch1
elif ratio > 0.80 and ratio <= 1.30:
elif ratio <= 1.30:
lux = 0.00146 * ch0 - 0.00112 * ch1
elif ratio > 1.30:
else:
lux = 0
# Pretty sure the floating point math formula on pg. 23 of datasheet
# is based on 16x gain and 402ms integration time. Need to scale
Expand Down