The Adafruit TSL2561 is a sophisticated digital luminosity sensor that offers ambient light sensing capabilities by measuring both visible and infrared light levels. This sensor is ideal for applications that require precise light measurements, such as adjusting display backlighting based on environmental lighting conditions or for general-purpose light sensing in home automation, industrial, and environmental monitoring systems.
Pin Number | Name | Description |
---|---|---|
1 | VDD | Power supply (2.7V to 3.6V) |
2 | GND | Ground connection |
3 | SDA | I2C Data |
4 | SCL | I2C Clock |
5 | ADDR | Address pin to set I2C address |
6 | INT | Interrupt output (active low) |
To use the TSL2561 sensor in a circuit:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
void setup(void) {
Serial.begin(9600);
Serial.println("Light Sensor Test"); Serial.println("");
// Initialise the sensor
if(!tsl.begin()) {
Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
while(1);
}
// Set the gain and integration time
tsl.setGain(TSL2561_GAIN_1X); // No gain ... use in bright light to avoid sensor saturation
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); // Fast but low resolution
// Display some basic information on this sensor
sensor_t sensor;
tsl.getSensor(&sensor);
Serial.println("------------------------------------");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux");
Serial.println("------------------------------------");
Serial.println("");
delay(500);
}
void loop(void) {
// Get a new sensor event
sensors_event_t event;
tsl.getEvent(&event);
// Display the results (light is measured in lux)
if (event.light) {
Serial.print(event.light); Serial.println(" lux");
} else {
// If event.light = 0 lux the sensor is probably saturated
// and no reliable data could be generated!
Serial.println("Sensor overload");
}
delay(250);
}
Q: Can the TSL2561 sensor measure UV light? A: No, the TSL2561 is designed to measure visible and infrared light, not ultraviolet light.
Q: What is the purpose of the ADDR pin? A: The ADDR pin allows you to change the I2C address of the sensor, enabling multiple sensors to be used on the same I2C bus.
Q: How do I know if the sensor is saturated? A: If the sensor is saturated, it will typically return a maximum reading or zero lux. Adjust the gain or integration time to avoid saturation.
For further assistance, consult the Adafruit TSL2561 datasheet and the Adafruit forums for community support.