TSL2561 Luminosity sensor

The TSL2561 luminosity sensor is a light sensor capable of detecting light levels in infrared, full-spectrum and human-visible light bands. Use the TSL2561 (About Modules) module for it.

Adafruit's sensor breakout board comes in two versions: the earlier is a 3.3V sensor, but in June 2014 the sensor was upgraded to include a voltage regulator to allow 5V as well. In either case, it should be powered from Espruino's 3.3V pin.

You can wire this up as follows:

Device Pin Espruino
Vcc / 3.3 (or Vin on Adafruit modules) 3.3
ADDR GND or 3.3 or N/C
Int N/C

Note: On Adafruit modules the 3Vo pin is the output of the voltage regulator and can be left disconnected

The address pin can be wired to GND, to 3.3V or left unconnected (N/C) to determine the I2C address used. This is selected in the module by initialising with C.LOW (GND), C.HIGH (3.3V) or C.FLOAT (N/C). This allows up to three TSL2561 sensors to be used per I2C bus.

The sensor supports gain of either 1x or 16x; as well as an integration time option (13ms, 101ms, or 402ms) that can be used to trade accuracy for speed/battery life. Ideally, the code would detect saturation or zero-value and adjust gain and integration time for optimum performance.

Similarly, calibration tables are specified for this device so an accurate conversion to Lux units is possible. The code for this conversion is partially implemented, but not complete.

The sensor also offers an Interrupt pin to wire to a standard GPIO pin to allow automatic collection of data once the integration time is complete. However, this is untested. Instead, a Javascript timeout is set to collect the data after a suitable time after initiation.

At this time, the module has only been significantly tested in the Visible spectrum, with an integration time of 101ms and a gain of 1x.

Basic usage:

  I2C1.setup({sda:B7, scl:B6});

  var tsl = require('TSL2561').connect(I2C1);


  var i = setInterval(function () {
      function (x) { print ("L="+x); }
  }, 1000);


You can get this sensor from several different places, including:

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.