adafruit / Adafruit_TSL2591_Library

This is an Arduino library for the TSL2591 digital luminosity (light) sensors.
58 stars 48 forks source link

[SOLVED] TSL2591 jumps from 0 to 65535 (saturation?) #20

Closed CaptainMack closed 6 years ago

CaptainMack commented 6 years ago

I'm using the current version of the library and the new lux calculation. However I still get the 65535. However, I am unsure if this can be related to another error (where it jumps from 0 to 65535) and the sensor has to be sampled more than 2 times? I've made a check within the calculateLux function to check for negative numbers.

My use-case is a station outside that measures lux with the TSL2591 and UV with Si1145 every 10 minutes (and goes to deep sleep inbetween)

It is configured with:

timing: TSL2591_INTEGRATIONTIME_100MS gain: TSL2591_GAIN_LOW

Rvice commented 6 years ago

Are you waiting between the power-on and the sensor reading?

At 100 ms integration time the max value is much less than 65535 (it should saturate at 36863 or slightly higher). Can you confirm I2C is not providing a NAK and you wait at least 100 ms from power up of the light sensor?

CaptainMack commented 6 years ago

Hi @Rvice

I think I solved it, but yes, I waited. The sensor was powered on, but in sleep between readings. However for reference, I solved it with the following configuration:

tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); tsl.setGain(TSL2591_GAIN_LOW);

And doing saturation checks (is reading a infinite number, not a number etc.) and filtering.

On sunny days, we can easily see +50.000 lux with a 100MS integration time.

Thanks,

I will close the issue from here

NuclearPhoenixx commented 6 years ago

Are you waiting between the power-on and the sensor reading?

The library does this automatically on itself, see:

  // Wait x ms for ADC to complete
  for (uint8_t d=0; d<=_integration; d++)
  {
    delay(120);
  }