Datasheet

getFullLuminosity reads both the IR and full spectrum sensors at the same time to allow
tigher correlation between the values, and then separates them in SW. The function returns
a 32-bit value which needs to be split into two 16-bit values, as shown in the code below:
calculateLux can be used to take both the infrared and visible spectrum sensor data and
roughly correlate with the equivalent SI lux value, based on a formula from the silicon vendor
that takes into account the sensor properties and the integration time and gain settings of
the device.
To calculate the lux, simple call calculateLux(full, ir), where 'full' and 'ir' are raw 16-bit
values taken from one of the two raw data functions above. See the code sample above for
an example of calculating lux.
//uint16_t x = tsl.getLuminosity(TSL2561_INFRARED);
Serial.print("[ "); Serial.print(millis()); Serial.print(" ms ] ");
Serial.print("Luminosity: ");
Serial.println(x, DEC);
}
/**************************************************************************/
/*
Show how to read IR and Full Spectrum at once and convert to lux
*/
/**************************************************************************/
void advancedRead(void)
{
// More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
// That way you can do whatever math and comparisons you want!
uint32_t lum = tsl.getFullLuminosity();
uint16_t ir, full;
ir = lum >> 16;
full = lum & 0xFFFF;
Serial.print("[ "); Serial.print(millis()); Serial.print(" ms ] ");
Serial.print("IR: "); Serial.print(ir); Serial.print(" ");
Serial.print("Full: "); Serial.print(full); Serial.print(" ");
Serial.print("Visible: "); Serial.print(full - ir); Serial.print(" ");
Serial.print("Lux: "); Serial.println(tsl.calculateLux(full, ir));
}
© Adafruit Industries https://learn.adafruit.com/adafruit-tsl2591 Page 20 of 22