The TSL2561 is a light-to-digital converter from TAOS. It senses light intensity and transforms its measurement into a digital output that is transferred over I2C or SMB. If you are familiar with the TSL230R light sensors, you shouldn’t have much trouble working with TSL2561s, but there are a few important differences. The TSL230R outputs its data as a pulse train, so a microcontroller with frequency counting code is required to read the sensor’s output. The TSL2561 outputs its data directly over I2C or SMB, so the sensor’s output is simply read from the bus. The TSL230R is controlled by bringing purpose specific pins high or low. The TSL2561 is controlled by writing data to it over the bus. The TSL230R is available in a breadboardable package and runs at 5V. The TSL2561 needs an adapter board for breadboarding and it’s power supply must not exceed 3.3V. The TSL2561 also has a second diode specifically for sensing infrared.
Since the TSL2561 is so similar to the TSL230R in theory, I’ll only be writing one condensed article for the TSL2561. Please refer to the series of article of the TSL230R for a more in-depth explanation of how to acquire and process data from these sensors.
TSL2561_DAQ.ino (view online) enables serial control of the TSL2561 via a simple serial protocol between the host computer and Arduino. It allows the user to set the number of output samples, adjust the TSL2561’s sensitivity and integration time, and switch power to a light source. The Arduino IDE has a built in serial monitor, which you can use for testing serial commands. However, Tod E. Kurt’s arduino-serial is smaller and has more functionality.
./arduino-serial -b 9600 -p /dev/ttyUSB0 -d 3000 -s s016 -d 100 -s i101 -d 100 -s l111 -d 100 -s t005 -d 10000 -r -d 500 -r -d 500 -r -d 500 -r -d 500 -r -d 500 -r -d 100 -s l000
Outputs one read for each -r:
This command waits three seconds for the bootloader to load the program (
-d 3000) then it tells the program to set the sensitivity to 16x (
s016), the integration time to 101 ms (
i101), turn the light on (
l111), and transmit five samples (
t005). The command then waits 10 seconds for the buffer to fill (
-d 10000), reads five samples (
-r -d 500 repeated five times), and finally turns the light off. The blank lines in the output are from the line feed (i.e. \n) printed after each number. The uc code uses
Serial.print('\n') instead of
Serial.println() and the string “EOT” so that it can communicate with code written for GNU Octave and MATLAB.
Data Acquisition Scripts
The archive TSL2561_code.zip contains the m-files (view online: get_data, save_data, serial_open) necessary for controlling the TSL2561 within GNU Octave and MATLAB and reading the counts output from the ATmega uc.
The spectral responsivity for the Channel 0 diode when the gain is 16x, the integration time is 101 ms, Vdd = 3V, and Ta = 25°C is saved in Re2561.mat in the essential_data_sets folder within the archive TSL2561_code.zip
Converting Counts to Irradiance
With Re(λ) and a model of the spectral content of the light source irradiating the photodiode array we can calculate the spectral irradiance and total irradiance of the light source more accurately than in the simplistic case of assuming all the light source’s photons are 640 nm in wavelength.
For example, if we model a red LED with a peak wavelength at 640 nm and a full width at half maximum (FWHM) of 34 nm with MATLAB like so:
% mathematically model lamp's spectrum as a gaussian curve with a peak
% wavelength at 640 nm and full width at half maximum of 34 nm
e = exp(1);
func_lamp = @(mu, FWHM) e.^(-2.7726*((lambda_Re-mu)/FWHM).^2);
X = func_lamp(640, 2*17); % [uW/(nm*cm^2)]
Then the output counts, cX, that would result if X irradiated the photodiode array can be calculated thusly:
However, cX is not the actual output counts of the TSL2561 because X is only a model of the shape of the light’s spectrum and lacks radiometric calibration. Since we can measure counts, finding the proper radiometric calibration multiplier for X is as simple as dividing counts/cX.
Therefore, a good approximation of the radiometrically calibrated spectral irradiance of the light source should be:
and the total irradiance is:
Newark gave me a TSL2561T light to digital converter from TAOS to evaluate as part of their product road testing program.
Thanks go out to ladyada for providing a library and basic example for working with the TSL2561.