The Flora TSL2561 Lux Sensor is a sophisticated light sensor that significantly surpasses the capabilities of simple photocells in many applications. It is designed to measure ambient light intensity with precision across a variety of lighting conditions. This sensor is particularly useful in projects where it is necessary to monitor light levels, such as in environmental monitoring, display backlight control, and general illumination measurement. It can be interfaced with the Adafruit Flora board or other microcontrollers, offering both analog and digital outputs for flexibility in various use cases.
Pin Number | Name | Description |
---|---|---|
1 | VDD | Power supply (2.7V - 3.6V) |
2 | GND | Ground connection |
3 | SDA | I2C Data |
4 | SCL | I2C Clock |
5 | INT | Interrupt (optional use) |
To use the Flora TSL2561 Lux Sensor with an Arduino UNO, you will need to include the appropriate libraries and write code to communicate with the sensor over the I2C bus.
#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
Serial.println("Sensor initialised.");
}
void loop(void) {
sensors_event_t event;
tsl.getEvent(&event);
// If event.light = 0 lux the sensor is probably saturated and no reliable data could be generated!
if (event.light) {
Serial.print(event.light); Serial.println(" lux");
} else {
Serial.println("Sensor overload");
}
delay(500);
}
Q: Can the sensor be used outdoors? A: Yes, but it should be protected from direct sunlight and harsh weather conditions to maintain accuracy and longevity.
Q: What is the purpose of the INT pin? A: The INT pin can be used to set up an interrupt that triggers when certain light thresholds are reached, reducing the need for constant polling by the microcontroller.
Q: How do I change the I2C address of the sensor? A: The I2C address is fixed for the Flora TSL2561 Lux Sensor and cannot be changed. If you need to connect multiple sensors, you may need an I2C multiplexer.
Q: Can the sensor measure infrared light? A: The TSL2561 is sensitive to both visible and infrared light, but it primarily measures visible light to determine lux levels.
For further assistance, consult the Adafruit TSL2561 Lux Sensor datasheet and the Adafruit forums for community support and additional resources.