recently I've started using TSL2591 with Python (library https://github.com/adafruit/Adafruit_Ci ... on_TSL2591)
My sensor:
Here is code, which i did for a test:
- Code: Select all | TOGGLE FULL SIZE
import board
import busio
import adafruit_tsl2591
from adafruit_tsl2591 import GAIN_HIGH, GAIN_MED, INTEGRATIONTIME_100MS, GAIN_MAX, \
INTEGRATIONTIME_600MS, INTEGRATIONTIME_300MS
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_tsl2591.TSL2591(i2c)
print("Gain: 0x10, integration_time: 100ms")
sensor.gain = GAIN_MED
sensor.integration_time = INTEGRATIONTIME_100MS
print('Light: {0} lux'.format(sensor.lux))
print('Visible: {0}'.format(sensor.visible))
print('Infrared: {0}'.format(sensor.infrared))
print("---------------------------------------")
print("Gain: 0x10, integration_time: 600ms")
sensor.gain = GAIN_MED
sensor.integration_time = INTEGRATIONTIME_300MS
print('Light: {0} lux'.format(sensor.lux))
print('Visible: {0}'.format(sensor.visible))
print('Infrared: {0}'.format(sensor.infrared))
print("---------------------------------------")
print("Gain: 0x30, integration_time: 100ms")
sensor.gain = GAIN_MAX
sensor.integration_time = INTEGRATIONTIME_100MS
print('Light: {0} lux'.format(sensor.lux))
print('Visible: {0}'.format(sensor.visible))
print('Infrared: {0}'.format(sensor.infrared))
print("---------------------------------------")
print("Gain: 0x30, integration_time: 600ms")
sensor.gain = GAIN_MAX
sensor.integration_time = INTEGRATIONTIME_600MS
print('Light: {0} lux'.format(sensor.lux))
print('Visible: {0}'.format(sensor.visible))
print('Infrared: {0}'.format(sensor.infrared))
In general it worked, but results which i got are different then described here: https://learn.adafruit.com/adafruit-tsl ... cuitpython .
My results
At dark place:
- Code: Select all | TOGGLE FULL SIZE
Gain: 0x10, integration_time: 100ms
Light: 10.405632 lux
Visible: 1048650
Infrared: 16
---------------------------------------
Gain: 0x10, integration_time: 600ms
Light: 0.004390117456460106 lux
Visible: 1048650
Infrared: 16
---------------------------------------
Gain: 0x30, integration_time: 100ms
Light: 0.026340704738760636 lux
Visible: 1048650
Infrared: 16
---------------------------------------
Gain: 0x30, integration_time: 600ms
Light: 0.004390117456460106 lux
Visible: 1048650
Infrared: 16
During day with bulb on:
- Code: Select all | TOGGLE FULL SIZE
Gain: 0x10, integration_time: 100ms
Light: 1689.361536 lux
Visible: 166670027
Infrared: 2543
---------------------------------------
Gain: 0x10, integration_time: 600ms
Light: 0.7127385986229242 lux
Visible: 166670027
Infrared: 2543
---------------------------------------
Gain: 0x30, integration_time: 100ms
Light: 4.276431591737546 lux
Visible: 166670027
Infrared: 2543
---------------------------------------
Gain: 0x30, integration_time: 600ms
Light: 0.7127385986229242 lux
Visible: 166670027
Infrared: 254
Moreover while I put switched on bulb really close to sensor, I got Python Exception:
- Code: Select all | TOGGLE FULL SIZE
Gain: 0x10, integration_time: 100ms
Traceback (most recent call last):
File "main.py", line 13, in <module>
print('Light: {0} lux'.format(sensor.lux))
File "/home/pi/Documents/tsl2591/project-name/.env/lib/python3.7/site-packages/adafruit_tsl2591.py", line 247, in lux
raise RuntimeError("Overflow reading light channels!")
RuntimeError: Overflow reading light channels!
I would expect that increasing GAIN would increase sensitivities of a sensor, the same with integration time.
Do you have any tip why I got results like that?
Moreover, why I'm getting RuntimeError exception? I'm getting this exception everytime, when I put a strong light on the sensor.