Arduino
Using the TSL2585 UVA and ambient light sensor with Arduino involves wiring up the sensor to your Arduino-compatible microcontroller, installing the Adafruit_TSL2585 library and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the TSL2585 VIN.
Here is an Adafruit Metro wired up to the TSL2585 using the STEMMA QT connector:
- Board 5V to breakout STEMMA VIN (red wire)
- Board GND to breakout STEMMA GND (black wire)
- Board SCL to breakout STEMMA SCL (yellow wire)
- Board SDA to breakout STEMMA SDA (blue wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
- Board 5V to breakout VIN (red wire)
- Board GND to breakout GND (black wire)
- Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
Library Installation
You can install the Adafruit TSL2585 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit TSL2585, and select the Adafruit TSL2585 library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
#include <Adafruit_TSL2585.h>
Adafruit_TSL2585 tsl2585;
void setup() {
Serial.begin(115200);
// Wait for the Serial Monitor to open on native USB boards.
// Remove this while (!Serial) loop to run without a USB connection.
while (!Serial) {
delay(10);
}
delay(250);
Serial.println("Adafruit TSL2585 photopic, infrared, and UVA sensor test");
if (!tsl2585.begin()) {
Serial.println("Could not find a TSL2585. Check the wiring and I2C address.");
while (true) {
delay(10);
}
}
Serial.print("Device ID: 0x");
Serial.println(tsl2585.getDeviceID(), HEX);
Serial.print("Revision ID: 0x");
Serial.println(tsl2585.getRevisionID(), HEX);
Serial.print("Factory UVA calibration byte: ");
Serial.println(tsl2585.getUVCalibration());
// Register-based results support integration times from 0.25 ms to 90 ms.
if (!tsl2585.setIntegrationTime(50)) {
Serial.println("Could not set the integration time.");
while (true) {
delay(10);
}
}
Serial.print("Integration time: ");
Serial.print(tsl2585.getIntegrationTime(), 2);
Serial.println(" ms");
Serial.println();
Serial.println("Photopic 1x\tInfrared 1x\tUVA 1x\tSaturated");
}
void loop() {
if (!tsl2585.dataReady()) {
delay(100);
return;
}
tsl2585_data_t data;
if (tsl2585.readData(&data)) {
bool saturated = false;
if (data.photopic_saturated || data.infrared_saturated ||
data.uva_saturated) {
saturated = true;
}
Serial.print(data.photopic_1x, 1);
Serial.print('\t');
Serial.print(data.infrared_1x, 1);
Serial.print('\t');
Serial.print(data.uva_1x, 1);
Serial.print('\t');
if (saturated) {
Serial.print("saturated");
}
Serial.println();
}
delay(100);
}
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You should see that the sketch has found your connected TSL2585 sensor. Then, when data is ready, you'll see the phototopic, infrared and UVA counts printed to the Serial Monitor, as well as if the sensor is saturated or not.
Page last edited September 15, 2026
Text editor powered by tinymce.