This module contains the driver for AMS TSL2561 Luminosity sensor integrating both infrared and full-spectrum photodiodes. The TSL2561 is capable of direct I2C communication and is able to conduct specific light ranges from 0.1 - 40k+ Lux easily. Additionally, it contains two integrating analog-to-digital converters (ADC) that convert currents from the two photodiodes, simultaneously (datasheet).
Creates an instance of a new TSL2561.
- i2cdrv – I2C Bus used ‘( I2C0, … )’
- addr – Slave address, default 0x49
- clk – Clock speed, default 400kHz
from ams.tsl2561 import tsl2561 ... tsl = tsl2561.TSL2561(I2C0, addr=tsl2561.TSL_I2C_ADDRESS["LOW"]) tsl.start() tsl.init() lux = tsl.get_lux()
This sensor has a dedicated “Address” pin that allows to select 1 of 3 available address as shown in the table below.
|ADDR SEL Terminal Level||I2C Address||Zerynth Define|
|GND||0x29||addr = tsl2561.TSL_I2C_ADDRESS[“LOW”]|
|Float||0x39||addr = tsl2561.TSL_I2C_ADDRESS[“NORMAL”]|
|Vdd||0x49||addr = tsl2561.TSL_I2C_ADDRESS[“HIGH”]|
Initialize the TSL2561 setting the gain, timing and kind of package.
gain – set the gain of the sensor (values allowed: 0 for gain=1x and 1 for gain=16x), default 1 -
timing – set the integration time value (from 0 to 2 - 0 for 13 ms, 1 for 101 ms, 2 for 402 ms), default 0 -
pack – set the kind of package for the correct lux calculation (values allowed: 0 for CS package and 1 for T,FN,CL package), default 1
Retrieves the current raw value read on channel0 (full-spectrum photodiode).
Retrieves the current raw value read on channel1 (infrared photodiode).
Retrieves the difference between the current raw value read on channel0 and raw value on channel1 (visible spectrum).
Returns raw_vis = (raw_fs - raw_ir).
Converts the raw sensor values to the standard SI lux equivalent (according to the sensor settings - gain, timing and kind of package).
Returns lux value or 0 if the sensor is saturated and the values are unreliable.