Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit TSL2561: Examples, Pinouts, and Specs

Image of Adafruit TSL2561Design with Adafruit TSL2561 in Cirkit Designer

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.

Explore Projects Built with Adafruit TSL2561

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of ESP8266 and TSL2561 Wi-Fi Connected Light Sensor: A project utilizing Adafruit TSL2561 in a practical application
ESP8266 and TSL2561 Wi-Fi Connected Light Sensor

This circuit consists of an ESP8266 NodeMCU microcontroller connected to a TSL2561 Lux Sensor. The microcontroller reads light intensity data from the sensor via I2C communication, with the SCL and SDA lines connected to D1 and D2 pins of the ESP8266, respectively. Power is supplied to the sensor through the 3V3 and GND pins of the ESP8266.

Open Project in Cirkit Designer

Technical Specifications

Key Features

Pin Configuration and Descriptions

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)

Usage Instructions

Integration with a Circuit

To use the TSL2561 sensor in a circuit:

  1. Connect the VDD pin to a 2.7V to 3.6V power supply.
  2. Connect the GND pin to the ground of the power supply.
  3. Connect the SDA and SCL pins to the I2C data and clock lines, respectively.
  4. The ADDR pin can be connected to GND or VDD to set the I2C address.
  5. The INT pin can be left unconnected if the interrupt feature is not used.

Best Practices

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

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.