Open sebadc opened 6 years ago
Looking at the equation, there are a few things missing.
Regarding actual measurements, I cannot comment on these.
The equation (calculateLux) should change to something like (with the visual channel added, maybe it shouldn't be):
// where gain is 1, 4, 16, 64
// where atime is the actual setting
max_count = 1025*(256-atime);
if(max_count >= 65535)
{
max_count = 65535;
}
if(visual >= max_count || r >= max_count || g >= max_count || b >= max_count)
{
return "OverFlow"
}
Lux = ((-0.32466f * r) + (1.57837f * g) + (-0.73191f * b)) / gain;
The ALS integration time is not taken into account too. This will also lead to incorrect values if the application does not scale down the RGB values correctly before calling the calculateLux
or calculateColorTemperature
method. Even with the default value of 10 for the iTimeMS
parameter in the begin
method, the RGB count values are already integrated over 3 ADC conversions.
Hi Guys. I am working whit an APDS-9960, I am try obtain the LUX and Color temperature with Adafruit library, but the result that I obtein is not real. If I read with a luxmeter the result is very diferent, Do you have any Examples with tested code?
My test code is:
include "Adafruit_APDS9960.h"
Adafruit_APDS9960 apds;
void setup() { Serial.begin(115200);
if(!apds.begin()){ Serial.println("failed to initialize device! Please check your wiring."); } else Serial.println("Device initialized!"); //enable color sensign mode apds.enableColor(true); }
void loop() { //create some variables to store the color data in uint16_t r, g, b, c; //wait for color data to be ready while(!apds.colorDataReady()){ delay(5); } //get the data and print the different channels apds.getColorData(&r, &g, &b, &c); Serial.print("red: "); Serial.print(r); Serial.print(" green: "); Serial.print(g); Serial.print(" blue: "); Serial.print(b); Serial.print(" clear: "); Serial.println(c); Serial.println(); float luz=apds.calculateLux(r,g,b); float color=apds.calculateColorTemperature(r,g,b); Serial.print (" LUXES: "); Serial.println (luz); Serial.print (" Color: "); Serial.println (color); delay(500); } Regards. Seba