You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Looking at the equation, there are a few things missing.
The Gain is not used in the equation for Lux, it likely should be (maybe just divide the computation by the gain?)
Overflow on any channel (visual, red, green and blue) are not checked for. This is a function of aTime (not values for 219 and 246 for atime do not reflect the equation 1025 * cycles)
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
The text was updated successfully, but these errors were encountered: