Hey guys I'm using a sensor to obtain light information using the adafruit library. After initialisation I use this code to read the data as recommended by Adafruit:
//### TSL2591
uint32_t TSL2591_Lum = TSL2591.getFullLuminosity();
uint16_t TSL2591_IR = TSL2591_Lum >> 16;
uint16_t TSL2591_Full = TSL2591_Lum & 0xFFFF;
uint16_t TSL2591_Visible = TSL2591_Full - TSL2591_IR;
uint16_t TSL2591_Lux = TSL2591.calculateLux(TSL2591_Full, TSL2591_IR);
However, on semi-rare occasions the IR readings are higher than the Full readings, which should not be logically possible as full should contain IR values. The "glitch" usually happens for one data point out of 100's or 1000s. This causes an integer wrap around when calculating visible and also breaks the calculateLux calculation. Any ideas ?why this is happening.
