Datasheet

Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.
Usage
To demonstrate the usage of the sensor we'll initialize it and read the luminosity from the board's Python REPL. Run
the following code to import the necessary modules and initialize the I2C connection with the sensor:
Remember if you're using a board that doesn't support hardware I2C (like the ESP8266) you need to use
the bitbangio module instead:
Now you're ready to read values from the sensor using any of these properties:
lux - The computed light lux value measured by the sensor.
visible - The visible light level measured by the sensor. This is a 32-bit unsigned value with no units, the higher
the number the more visible light.
infrared - The infrared light level measured by the sensor. This is a 16-bit unsigned value with no units, the
higher the number the more infrared light.
full_spectrum - The visible & infrared light level measured by the sensor as a single 32-bit value with no units.
The higher the number the more full spectrum light.
raw_luminosity - A 2-tuple of raw sensor visible+IR and IR only light levels. Each is a 16-bit value with no units
where the higher the value the more light.
In addition you can read and write a few properties to change how the sensor behaves and is configured:
gain - Set this to a value below to change the gain of the light sensor:
adafruit_tsl2591.GAIN_LOW - 1x gain
import board
import busio
import adafruit_tsl2591
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_tsl2591.TSL2591(i2c)
import board
import bitbangio
import adafruit_tsl2591
i2c = bitbangio.I2C(board.SCL, board.SDA)
sensor = adafruit_tsl2591.TSL2591(i2c)
print('Light: {0}lux'.format(sensor.lux))
print('Visible: {0}'.format(sensor.visible))
print('Infrared: {0}'.format(sensor.infrared))
© Adafruit Industries https://learn.adafruit.com/adafruit-tsl2591 Page 21 of 24