Datasheet

reference, which will be populated by the function, and then read the results, as shown in the
following code:
void getSensor(sensor_t*)
This function returns some basic information about the sensor, and operates in a similar
fashion to getEvent. You pass in an empty sensor_t reference, which will be populated by
this function, and we can then read the results and retrieve some key details about the
sensor and driver, as shown in the code below:
/**************************************************************************/
/*
Performs a read using the Adafruit Unified Sensor API.
*/
/**************************************************************************/
void unifiedSensorAPIRead(void)
{
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);
/* Display the results (light is measured in lux) */
Serial.print("[ "); Serial.print(event.timestamp); Serial.print(" ms ] ");
if ((event.light == 0) |
(event.light > 4294966000.0) |
(event.light <-4294966000.0))
{
/* If event.light = 0 lux the sensor is probably saturated */
/* and no reliable data could be generated! */
/* if event.light is +/- 4294967040 there was a float over/underflow */
Serial.println("Invalid data (adjust gain or timing)");
}
else
{
Serial.print(event.light); Serial.println(" lux");
}
}
Note that some checks need to be performed on the sensor data in case the sensor
saturated. If saturation happens, please adjust the gain and integration time up or down
to change the sensor's sensitivity and output range.
/**************************************************************************/
/*
© Adafruit Industries https://learn.adafruit.com/adafruit-tsl2591 Page 18 of 22