Skip to main content

tsl2561

High dynamic range light sensor measuring visible and infrared light via I2C.

Overview

The tsl2561 node reads light intensity from the TSL2561 sensor. This sensor has two photodiodes - one for visible+IR and one for IR only - allowing accurate lux calculation and separate visible/IR readings. Great for grow lights, photography, and scientific applications.

0.1-40k
Lux Range
Dual
Photodiodes
Auto
Gain Control
I2C
Interface

Properties

Property Type Default Description
address number 0x39 I2C address (0x29, 0x39, or 0x49)
gain string "auto" "auto", "1x", or "16x"
integration number 402 Integration time: 13, 101, or 402 ms
interval number 1000 Reading interval (ms)

Output

{
  "payload": {
    "lux": 542.3,
    "visible": 12450,
    "infrared": 3200,
    "fullSpectrum": 15650
  },
  "lux": 542.3,
  "timestamp": 1640000000000
}

Example: Grow Light Optimization

Monitor light spectrum for indoor plants and control supplemental lighting.

// Function node: Grow light control
var lux = msg.payload.lux;
var visible = msg.payload.visible;
var ir = msg.payload.infrared;

// Calculate visible/IR ratio (plants need more visible)
var ratio = visible / (ir + 1); // +1 to avoid divide by zero

var recommendation = "";
var lightAction = "off";

if (lux < 2000) {
    recommendation = "Very low light - turn on grow lights";
    lightAction = "full";
} else if (lux < 5000) {
    recommendation = "Low light - supplement with grow lights";
    lightAction = "partial";
} else if (lux > 50000) {
    recommendation = "Too bright - consider shade";
    lightAction = "off";
} else {
    recommendation = "Good light levels";
    lightAction = "off";
}

msg.payload = {
    lux: lux,
    visibleIrRatio: ratio.toFixed(2),
    recommendation: recommendation,
    lightAction: lightAction
};

return msg;

Related Nodes