TSL2561 Light Intensity Measurement

Light Intensity Measurement with TSL2561

Introduction

This experiment demonstrates how to use the TSL2561 light sensor with Arduino to measure light intensity.

TSL2561 Light Sensor

Components Needed

Circuit Setup

  1. Connect the TSL2561 sensor to the Arduino using the I2C pins (SDA, SCL).
  2. Connect the sensor's VCC and GND pins to the Arduino's 5V and GND pins, respectively.

This setup allows the Arduino to communicate with the sensor over I2C.

TSL2561 Circuit Setup

Code for Light Intensity Measurement

Upload the following code to your Arduino to read light intensity values:


#include 
#include 

Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, &Wire);

void setup() {
  Serial.begin(9600);
  if (!tsl.begin()) {
    Serial.println("Couldn't find TSL2561 sensor");
    while (1);
  }
  tsl.setGain(TSL2561_GAIN_16X);  // Set the gain for the sensor
}

void loop() {
  sensors_event_t event;
  tsl.getEvent(&event);
  if (event.light) {
    Serial.print("Light Intensity: ");
    Serial.print(event.light);
    Serial.println(" lux");
  } else {
    Serial.println("No light detected");
  }
  delay(500);
}
            

Explanation

The code reads the light intensity from the TSL2561 sensor and displays the value in lux on the Serial Monitor.

Troubleshooting