Adafruit_SI1145_Library
Adafruit_SI1145_Library copied to clipboard
add dark frame calibration and add calculateLux method as per Si114x AN523
... aka make the SI1145 more useful on the Arduino.
The SI1145 datasheet is quoted as saying:
Accurate lux measurements with IR correction algorithm
It's hard to determine exactly what the algorithm is until looking at their SI1145 AN523 application note. The lux calculation is given as such:
Lux level = [ [(ALS visible reading) - (ALS visible dark reading)] x (ALS visible coefficient) +
[ (ALSIR reading) - (ALS IR dark reading)] x (ALS IR coefficient) ] x gain correction
The dark readings are absolute minimums reported by the sensor in "absolute" darkness, and the coefficients are gleaned from the table in AN523.6. I have changed the Adafruit_SI1145 class to keep track of the absolute minimums of the VIS and IR channels and use them for dark frame subtraction. The initial dark values were determined by covering the sensor with a black cloth.
I have also exposed an API for adjusting the gain on the visible and IR channels.
I have a TSL2561, TSL2591 and SI1145 hooked up to my Arduino Uno's I2C bus and the EV calculations are in relative agreement.
TSL2561 IR: 88 Full: 228 Lux: 94.00 EV: 3.63
TSL2591 IR: 94 Full: 232 Lux: 63.517436 EV: 3.24
SI1145 IR: 14 Full: 12 Lux: 63.799999 EV: 3.24
TSL2561 IR: 86 Full: 225 Lux: 94.00 EV: 3.63
TSL2591 IR: 93 Full: 227 Lux: 60.775676 EV: 3.19
SI1145 IR: 14 Full: 13 Lux: 69.209999 EV: 3.32
TSL2561 IR: 83 Full: 219 Lux: 93.00 EV: 3.62
TSL2591 IR: 90 Full: 221 Lux: 59.894393 EV: 3.18
SI1145 IR: 13 Full: 13 Lux: 69.290000 EV: 3.32