The Adafruit TSL2591 is a sophisticated digital light sensor that offers high dynamic range detection of ambient light intensity. It is capable of measuring illuminance from deep dark (188 µLux) to bright sunlight (88,000 Lux) with an extended range. This sensor is ideal for applications that require precise light measurements, such as screen brightness adjustments in smartphones, industrial lighting systems, and environmental monitoring.
Pin Number | Name | Description |
---|---|---|
1 | VIN | Supply voltage (3.3V to 5V) |
2 | GND | Ground connection |
3 | SCL | I2C clock line |
4 | SDA | I2C data line |
5 | INT | Interrupt output (active low) |
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2591.h>
// Create the TSL2591 sensor object
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);
void setup() {
Serial.begin(9600);
// Initialize the sensor
if (tsl.begin()) {
Serial.println("Started sensor successfully.");
} else {
Serial.println("No sensor found. Check your wiring.");
while (1);
}
// Set the gain and integration time
tsl.setGain(TSL2591_GAIN_MED); // Medium gain
tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS); // 300ms integration time
// Uncomment to enable the interrupt feature on the sensor
// tsl.registerInterrupt(500, 10000);
}
void loop() {
// Read the visible + IR diode from the sensor
uint32_t lumens = tsl.getFullLuminosity();
// Calculate the actual lux value
uint16_t lux = tsl.calculateLux(lumens >> 16, lumens & 0xFFFF);
// Print the results to the Serial Monitor
Serial.print("Lux: ");
Serial.println(lux);
delay(1000); // Wait for 1 second before the next reading
}
Serial.println()
function to debug and track down where the issue might be occurring in your code.Q: Can the TSL2591 sensor measure UV light? A: No, the TSL2591 is designed to measure visible and infrared light, not ultraviolet light.
Q: Is it necessary to calibrate the sensor? A: The TSL2591 comes factory-calibrated, but for critical applications, you may perform additional calibration against a known light source.
Q: How can I change the I2C address of the sensor? A: The TSL2591 has a fixed I2C address and cannot be changed. If you need to connect multiple sensors, you will need an I2C multiplexer.
Q: What is the purpose of the INT pin? A: The INT pin can be used to trigger an interrupt on the microcontroller when certain light thresholds are reached, reducing the need for constant polling of the sensor.
This documentation provides a comprehensive guide to the Adafruit TSL2591 High Dynamic Range Digital Light Sensor, ensuring users can effectively integrate and utilize this component in their projects.