adafruit_tsl2591
¶
CircuitPython module for the TSL2591 precision light sensor. See examples/simpletest.py for a demo of the usage.
Author(s): Tony DiCola
Implementation Notes¶
Hardware:
Adafruit TSL2591 High Dynamic Range Digital Light Sensor (Product ID: 1980)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- adafruit_tsl2591.GAIN_HIGH = 32¶
High gain (428x)
- adafruit_tsl2591.GAIN_LOW = 0¶
Low gain (1x)
- adafruit_tsl2591.GAIN_MAX = 48¶
Max gain (9876x)
- adafruit_tsl2591.GAIN_MED = 16¶
Medium gain (25x)
- adafruit_tsl2591.INTEGRATIONTIME_100MS = 0¶
100 millis
- adafruit_tsl2591.INTEGRATIONTIME_200MS = 1¶
200 millis
- adafruit_tsl2591.INTEGRATIONTIME_300MS = 2¶
300 millis
- adafruit_tsl2591.INTEGRATIONTIME_400MS = 3¶
400 millis
- adafruit_tsl2591.INTEGRATIONTIME_500MS = 4¶
500 millis
- adafruit_tsl2591.INTEGRATIONTIME_600MS = 5¶
600 millis
- class adafruit_tsl2591.TSL2591(i2c, address=41)[source]¶
TSL2591 high precision light sensor.
- Parameters
Quickstart: Importing and using the device
Here is an example of using the
TSL2591
class. First you will need to import the libraries to use the sensorimport board import adafruit_tsl2591
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA sensor = adafruit_tsl2591.TSL2591(i2c)
Now you have access to the
lux
,infrared
visible
andfull_spectrum
attributeslux = sensor.lux infrared = sensor.infrared visible = sensor.visible full_spectrum = sensor.full_spectrum
- property full_spectrum¶
Read the full spectrum (IR + visible) light and return its value as a 32-bit unsigned number.
- property gain¶
Get and set the gain of the sensor. Can be a value of:
GAIN_LOW
(1x)GAIN_MED
(25x)GAIN_HIGH
(428x)GAIN_MAX
(9876x)
- property infrared¶
Read the infrared light and return its value as a 16-bit unsigned number.
- property integration_time¶
Get and set the integration time of the sensor. Can be a value of:
INTEGRATIONTIME_100MS
(100 millis)INTEGRATIONTIME_200MS
(200 millis)INTEGRATIONTIME_300MS
(300 millis)INTEGRATIONTIME_400MS
(400 millis)INTEGRATIONTIME_500MS
(500 millis)INTEGRATIONTIME_600MS
(600 millis)
- property lux¶
Read the sensor and calculate a lux value from both its infrared and visible light channels.
Note
lux
is not calibrated!
- property raw_luminosity¶
Read the raw luminosity from the sensor (both IR + visible and IR only channels) and return a 2-tuple of those values. The first value is IR + visible luminosity (channel 0) and the second is the IR only (channel 1). Both values are 16-bit unsigned numbers (0-65535).
- property visible¶
Read the visible light and return its value as a 32-bit unsigned number.