Introduction
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.
Technical Specifications
Key Features
- Resolution: 16-bit digital output at 400 kHz I2C Fast-Mode
- Dynamic Range: 0.1 - 40,000+ Lux
- Interface: I2C
- Supply Voltage: 2.7V to 3.6V
- Operating Temperature: -30°C to 80°C
Pin Configuration and Descriptions
Usage Instructions
Integration with a Circuit
To use the TSL2561 sensor in a circuit:
- Connect the VDD pin to a 2.7V to 3.6V power supply.
- Connect the GND pin to the ground of the power supply.
- Connect the SDA and SCL pins to the I2C data and clock lines, respectively.
- The ADDR pin can be connected to GND or VDD to set the I2C address.
- The INT pin can be left unconnected if the interrupt feature is not used.
Best Practices
- Ensure that the power supply voltage does not exceed the maximum rating.
- Use pull-up resistors on the I2C data and clock lines, typically 4.7kΩ to 10kΩ.
- Avoid placing the sensor in direct sunlight or near strong infrared sources to prevent saturation.
Example Code for Arduino UNO
#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);
}
Troubleshooting and FAQs
Common Issues
- Sensor not detected: Ensure that the wiring is correct and that the correct I2C address is used in the code.
- Inaccurate readings: Check if the sensor is placed in a stable lighting environment and is not affected by external light sources.
- Sensor saturation: If the sensor is exposed to too much light, it may become saturated. Try reducing the gain or increasing the integration time.
FAQs
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.