diff --git a/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp b/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp index 230ef6294..1cd9a9de3 100644 --- a/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp +++ b/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp @@ -338,7 +338,15 @@ float Adafruit_TSL2591::calculateLux(uint16_t ch0, uint16_t ch1) // Alternate lux calculation 1 // See: https://github.com/adafruit/Adafruit_TSL2591_Library/issues/14 - lux = ( ((float)ch0 - (float)ch1 )) * (1.0F - ((float)ch1/(float)ch0) ) / cpl; + if(ch0 > 0) + { + lux = ( ((float)ch0 - (float)ch1 )) * (1.0F - ((float)ch1/(float)ch0) ) / cpl; + } + else + { + lux = 0.0F; + } + // Alternate lux calculation 2 //lux = ( (float)ch0 - ( 1.7F * (float)ch1 ) ) / cpl;