

The TSL2561 is a digital light sensor designed to measure light intensity in lux. It features a built-in Analog-to-Digital Converter (ADC) and communicates via the I2C protocol, enabling precise and reliable light measurements. Unlike traditional light sensors, the TSL2561 can measure both infrared and visible light, making it ideal for applications requiring accurate ambient light sensing.








The TSL2561 is a highly versatile sensor with the following key specifications:
| Parameter | Value |
|---|---|
| Operating Voltage | 2.7V to 3.6V |
| Communication Interface | I2C |
| Lux Range | 0.1 to 40,000 lux |
| Operating Temperature | -30°C to 70°C |
| Power Consumption | 0.6 mW (typical) |
| ADC Resolution | 16-bit |
| I2C Address (Default) | 0x39 |
The TSL2561 sensor typically comes in an 8-pin package. Below is the pinout description:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | VDD | Power supply (2.7V to 3.6V) |
| 3 | SDA | I2C data line |
| 4 | SCL | I2C clock line |
| 5 | INT | Interrupt output (optional, for event signaling) |
| 6-8 | NC | Not connected (leave unconnected or grounded) |
Below is an example of how to interface the TSL2561 with an Arduino UNO using the Adafruit TSL2561 library:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
// Create an instance of the TSL2561 sensor
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
void setup() {
Serial.begin(9600);
Serial.println("Initializing TSL2561...");
// Initialize the sensor
if (!tsl.begin()) {
Serial.println("TSL2561 not detected. Check wiring!");
while (1);
}
// Configure the sensor
tsl.enableAutoRange(true); // Automatically adjust gain
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); // Short integration time
Serial.println("TSL2561 initialized successfully.");
}
void loop() {
sensors_event_t event;
tsl.getEvent(&event);
if (event.light) {
// Print the light intensity in lux
Serial.print("Light Intensity: ");
Serial.print(event.light);
Serial.println(" lux");
} else {
// If no light is detected
Serial.println("No light detected.");
}
delay(1000); // Wait 1 second before the next reading
}
Adafruit_TSL2561_U.h library simplifies communication with the sensor.enableAutoRange function adjusts the gain automatically for optimal readings.Sensor Not Detected
Inaccurate Lux Readings
I2C Communication Errors
No Light Detected
Q: Can the TSL2561 measure UV light?
A: No, the TSL2561 is designed to measure visible and infrared light, not UV light.
Q: What is the maximum distance for I2C communication?
A: The I2C bus is typically reliable up to 1 meter. For longer distances, consider using I2C extenders.
Q: Can I use the TSL2561 with a 5V microcontroller?
A: Yes, but you must use a logic level shifter to safely interface the 3.3V sensor with a 5V microcontroller.
Q: How do I calculate lux manually from raw sensor data?
A: Refer to the TSL2561 datasheet for the formula to convert raw channel data to lux based on the gain and integration time.
By following this documentation, you can effectively integrate the TSL2561 digital light sensor into your projects for accurate and reliable light measurements.