adafruit / Adafruit_TSL2561

Unified sensor driver for Adafruit's TSL2561 breakouts
85 stars 77 forks source link

Fix negative lux value check. #20

Closed mvn23 closed 5 years ago

mvn23 commented 5 years ago

Rewrite negative lux value check to avoid comparing unsigned long < 0. Modifies Adafruit_TSL2561_U.cpp.

Prevents returning unrealistic lux values when (channel0 * b) < (channel1 * m)

hoffmannjan commented 5 years ago

@ladyada looks ok, but not sure as don't have this chip

ladyada commented 5 years ago

k yeah this chip was discontinued but you can get breakouts on ebay and such

mvn23 commented 5 years ago

Without this patch I got readings of 262143 (2^18 - 1) lux every once in a while, especially in low light conditions. I traced it back to these few lines and haven't seen any occurences since applying the fix. The TSL2561 is on a breakout board connected to a Wemos D1 mini.

hoffmannjan commented 5 years ago

got this chip now, works fine with this patch :)