Reports.AdafruitTSL2561 History

Hide minor edits - Show changes to output

Changed line 1 from:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to achieve this.
to:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to pick up IR, UV, and Visible Light.
Changed lines 1-4 from:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to achieve this. I am using [[Lady Ada’s guide] | http://www.ladyada.net/learn/sensors/tsl2561.html ] and library. In Lady Ada’s example, she uses a regular arduino, where the I2C Data and CLk are pins are pins 4 and 5. I was using a mega which its Data and CLK are pins 20 and 21. In Arduino, the I2C pins are preset. In the example, ladyada prints out the IR, full spectrum, visible, and lux. The sensor maxes out at around 4935.

to:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to achieve this.

I am using Lady Ada’s guide and library.

http://www.ladyada.net/learn/sensors/tsl2561.html
https://github.com/adafruit/TSL2561-Arduino-Library


Datasheet
http://www.adafruit.com/datasheets/TSL2561.pdf

In
Lady Ada’s example, she uses a regular arduino, where the I2C Data and CLk are pins are pins 4 and 5. I was using a mega which its Data and CLK are pins 20 and 21. In Arduino, the I2C pins are preset. In the example, ladyada prints out the IR, full spectrum, visible, and lux. The sensor maxes out at around 4935.
Changed lines 1-5 from:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to achieve this. I am using Lady Ada’s guide and library. In Lady Ada’s example, she uses a regular arduino, where the I2C Data and CLk are pins are pins 4 and 5. I was using a mega which its Data and CLK are pins 20 and 21. In Arduino, the I2C pins are preset. In the example, ladyada prints out the IR, full spectrum, visible, and lux. The sensor maxes out at around 4935.
to:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to achieve this. I am using [[Lady Ada’s guide] | http://www.ladyada.net/learn/sensors/tsl2561.html ] and library. In Lady Ada’s example, she uses a regular arduino, where the I2C Data and CLk are pins are pins 4 and 5. I was using a mega which its Data and CLK are pins 20 and 21. In Arduino, the I2C pins are preset. In the example, ladyada prints out the IR, full spectrum, visible, and lux. The sensor maxes out at around 4935.
Changed line 147 from:
(:sourceend:)
to:
(:sourceend:)
Changed lines 8-11 from:

[img]
http://farm8.staticflickr.com/7193/6810906612_941847237c.jpg[/img]

to:
http://farm8.staticflickr.com/7193/6810906612_941847237c.jpg
Changed lines 9-10 from:
[url=http://www.flickr.com/photos/zevenrodriguez/6810906612/][img]http://farm8.staticflickr.com/7193/6810906612_941847237c.jpg[/img][/url]
[url=http://www.flickr.com/photos/zevenrodriguez/6810906612/]tsl2561output[/url] by [url=http://www.flickr.com/people/zevenrodriguez/]zevenwolf[/url], on Flickr
to:
[img]http://farm8.staticflickr.com/7193/6810906612_941847237c.jpg[/img]
Added lines 1-149:
The TSL2561 is a full spectrum light sensor. I uses 3 light sensors to achieve this. I am using Lady Ada’s guide and library. In Lady Ada’s example, she uses a regular arduino, where the I2C Data and CLk are pins are pins 4 and 5. I was using a mega which its Data and CLK are pins 20 and 21. In Arduino, the I2C pins are preset. In the example, ladyada prints out the IR, full spectrum, visible, and lux. The sensor maxes out at around 4935.




These readings were taken indoors in a room


[url=http://www.flickr.com/photos/zevenrodriguez/6810906612/][img]http://farm8.staticflickr.com/7193/6810906612_941847237c.jpg[/img][/url]
[url=http://www.flickr.com/photos/zevenrodriguez/6810906612/]tsl2561output[/url] by [url=http://www.flickr.com/people/zevenrodriguez/]zevenwolf[/url], on Flickr


This is the code used to generate the readings above.
(:source lang=arduino tabwidth=4 :)

#include <Wire.h>
#include “TSL2561.h”

// Example for demonstrating the TSL2561 library – public domain!

// connect SCL to analog 5
// connect SDA to analog 4
// connect VDD to 3.3V DC
// connect GROUND to common ground
// ADDR can be connected to ground, or vdd or left floating to change the i2c address

// The address will be different depending on whether you let
// the ADDR pin float (addr 0×39), or tie it to ground or vcc. In those cases
// use TSL2561_ADDR_LOW (0×29) or TSL2561_ADDR_HIGH (0×49) respectively
TSL2561 tsl(TSL2561_ADDR_FLOAT);

void setup(void) {
Serial.begin(9600);

if (tsl.begin()) {
Serial.println(“Found sensor”);
} else {
Serial.println(“No sensor?”);
while (1);
}

// You can change the gain on the fly, to adapt to brighter/dimmer light situations
//tsl.setGain(TSL2561_GAIN_0X); // set no gain (for bright situtations)
tsl.setGain(TSL2561_GAIN_16X); // set 16x gain (for dim situations)

// Changing the integration time gives you a longer time over which to sense light
// longer timelines are slower, but are good in very low light situtations!
tsl.setTiming(TSL2561_INTEGRATIONTIME_13MS); // shortest integration time (bright light)
//tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light)
//tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light)

// Now we’re ready to get readings!
}

void loop(void) {
// Simple data read example. Just read the infrared, fullspecrtrum diode
// or ‘visible’ (difference between the two) channels.
// This can take 13-402 milliseconds! Uncomment whichever of the following you want to read
// uint16_t x = tsl.getLuminosity(TSL2561_VISIBLE);
//uint16_t x = tsl.getLuminosity(TSL2561_FULLSPECTRUM);
//uint16_t x = tsl.getLuminosity(TSL2561_INFRARED);
//Serial.println(x, DEC);

// More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
// That way you can do whatever math and comparions you want!
uint32_t lum = tsl.getFullLuminosity();
uint16_t ir, full;
ir = lum >> 16;
full = lum & 0xFFFF;
Serial.print(“IR: “); Serial.print(ir); Serial.print(“\t\t”);
Serial.print(“Full: “); Serial.print(full); Serial.print(“\t”);
Serial.print(“Visible: “); Serial.print(full – ir); Serial.print(“\t”);
Serial.print(“Lux: “); Serial.println(tsl.calculateLux(full, ir));
Serial.print(“\n”);
delay(100);
}


(:sourceend:)



In this snippet of code, she uses the concept of Bit Math. For more information on this portion of the code read http://www.arduino.cc/playground/Code/BitMath
(:source lang=arduino tabwidth=4 :)

ir = lum >> 16;

full = lum & 0xFFFF;

(:sourceend:)


For a simpler example where you just want access to a certain part of the sensor you would use the getLuminosity() function and pass TSL2561_VISIBLE, TSL2561_FULLSPECTRUM, TSL2561_INFRARED into it.

(:source lang=arduino tabwidth=4 :)


#include <Wire.h>
#include “TSL2561.h”

// Example for demonstrating the TSL2561 library – public domain!

// connect SCL to analog 5
// connect SDA to analog 4
// connect VDD to 3.3V DC
// connect GROUND to common ground
// ADDR can be connected to ground, or vdd or left floating to change the i2c address

// The address will be different depending on whether you let
// the ADDR pin float (addr 0×39), or tie it to ground or vcc. In those cases
// use TSL2561_ADDR_LOW (0×29) or TSL2561_ADDR_HIGH (0×49) respectively
TSL2561 tsl(TSL2561_ADDR_FLOAT);

void setup(void) {
Serial.begin(9600);

if (tsl.begin()) {
Serial.println(“Found sensor”);
} else {
Serial.println(“No sensor?”);
while (1);
}

// You can change the gain on the fly, to adapt to brighter/dimmer light situations
//tsl.setGain(TSL2561_GAIN_0X); // set no gain (for bright situtations)
tsl.setGain(TSL2561_GAIN_16X); // set 16x gain (for dim situations)

// Changing the integration time gives you a longer time over which to sense light
// longer timelines are slower, but are good in very low light situtations!
tsl.setTiming(TSL2561_INTEGRATIONTIME_13MS); // shortest integration time (bright light)
//tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light)
//tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light)

// Now we’re ready to get readings!
}

void loop(void) {
// Simple data read example. Just read the infrared, fullspecrtrum diode
// or ‘visible’ (difference between the two) channels.
// This can take 13-402 milliseconds! Uncomment whichever of the following you want to read
// uint16_t x = tsl.getLuminosity(TSL2561_VISIBLE);
uint16_t x = tsl.getLuminosity(TSL2561_FULLSPECTRUM);
//uint16_t x = tsl.getLuminosity(TSL2561_INFRARED);
Serial.println(x, DEC);
delay(100);
}


(:sourceend:)