[TSL2591 Sensor] Tips needed with the Arduino Code

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Eiffel
 
Posts: 3
Joined: Tue Oct 16, 2018 4:25 am

[TSL2591 Sensor] Tips needed with the Arduino Code

Post by Eiffel »

Hi there !
I'm currently working with the TSL2591 light sensor, wired with an Arduino Uno.
For an industrial application, I've to quantify the ambient luminosity to calculate another sensor's uncertainty of measurement.
My code is perfectly working but I still have a few "black spots" and I need some tips.
I've got three questions about the functions used in the manual ( https://learn.adafruit.com/adafruit-tsl ... g-and-test )
1 - Is there any logical reason (maths/abacus/...) to set the gain and the integration time ? Or should I set it up just by a feeling ?
2 - Why the function ".getTiming" is incremented and multiplicated by 100 ? I really don't get it...
3 - What is the transfert function used by ".calculatedLux" ?
Thanks already !

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: [TSL2591 Sensor] Tips needed with the Arduino Code

Post by adafruit_support_bill »

1) Ideally, you would select a gain and integration time that gives you readings somewhere in the mid range of the sensor. Increasing gain will also increase the noise in the readings. Increasing integration time makes readings slower. For best accuracy, use the lowest gain that give you reasonable readings. For fastest performance, use the lowest integration time that gives you reasonable readings..

2) Because internally, the times are represented as a zero-based integer enumeration.

3) You can see this startig on line 220 in the source code: https://github.com/adafruit/Adafruit_TS ... SL2591.cpp

User avatar
Eiffel
 
Posts: 3
Joined: Tue Oct 16, 2018 4:25 am

Re: [TSL2591 Sensor] Tips needed with the Arduino Code

Post by Eiffel »

Thanks for those answers ! Point 1 and 2 are way much clean now !
But about 3), I've found the formula, but the parameters aren't clear.

Basic formula : lux = (fullspec - IR) * [1.0F - (IR/fullspec)] / [(atime*again)/TSL2591_LUX_DF]

=> 1.0F : what means this coefficient ? I know that is a float number, but why choosing this number, what does it means ?
=> TSL2591_LUX_DF : same question, I can't find it in the source code...

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: [TSL2591 Sensor] Tips needed with the Arduino Code

Post by adafruit_support_bill »

The constants are defined in the header file: https://github.com/adafruit/Adafruit_TS ... _TSL2591.h

As for the derivation of the lux calculation, the manufacturer is fairly vague on the subject. The data sheet only says this:
This digital output can be input to a
microprocessor where illuminance (ambient light level) in lux is
derived using an empirical formula to approximate the human
eye response.
See some discussion on the topic here.

https://github.com/adafruit/Adafruit_Ci ... 1/issues/7

User avatar
Eiffel
 
Posts: 3
Joined: Tue Oct 16, 2018 4:25 am

Re: [TSL2591 Sensor] Tips needed with the Arduino Code

Post by Eiffel »

Thanks again !

Now I'm trying the ".light" function from the "sensors_event_t" type.
1) The lux output includes IR, Fullsectrum or only the visible field ?
2) What's the transfert function used by ".light" ? I can't find it in the source code...

Wainting for your anwers ☺

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”