TSL2591 runtime error: Overflow reading light channels



  • Hello there! :)
    I have a TSL2591 light sensor with this library. I use this sensor to mesure light from a special kind of partly infra led lamp.
    Based on the datasheet this sensor should be good up to 88000 lux which is huge. But I get Overflow errors from around 2940 lux.
    This is one okay measurement, above that its runtime error(overflow):

    Total light: 2935.916 lux
    infrared light: 11313
    Visible light: 741434001
    full spectrum(IR+ visible) light: 741445314
    

    Can you gave me a tip, what am I do wrong?
    Thank you! :)



  • It looks like you are using signed intergers/numbers for the reading from the light sensor. When it reaches the half way value it wraps around and goes negative.

    If you simply define the data as an unsigned type does it fix the issue.



  • I am running into the same issue. Did you find any solution?



  • I tried to mess around with gain. Tried out every possibility, but no luck.



  • I took out the checks where the overflow exception is rased. And after 3000 lumen the values start to decrease... so I turn up the know on the lamp, goes up to 3000 then down to -1600.



  • I digged into the library little bit, and I found out the the error is raised because channel_0 is ?too low? and channel_0 is getting his value from here _TSL2591_REGISTER_CHAN0_LOW = const(0x14).
    Not much, but still digging.



Pycom on Twitter