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
I am running multiple TCS34725 sensors for some months now for environmental monitoring. I realized that the function "calculateLux" returns 65535 in some low-light-conditions:
Library-Included version of "calculateLux" function:
uint16_t Adafruit_TCS34725::calculateLux(uint16_t r, uint16_t g, uint16_t b) {
float illuminance;
/* This only uses RGB ... how can we integrate clear or calculate lux */
/* based exclusively on clear since this might be more reliable? */
illuminance = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
return (uint16_t)illuminance;
}
Proposed modification of "calculateLux" function:
uint16_t Adafruit_TCS34725::calculateLux(uint16_t r, uint16_t g, uint16_t b) {
float illuminance;
/* This only uses RGB ... how can we integrate clear or calculate lux */
/* based exclusively on clear since this might be more reliable? */
illuminance = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
if (illuminance < 0) { // This line is added
illuminance = 0; // This line is added
} // This line is added
return (uint16_t)illuminance;
}
Maybe there are better ways to make this function more robust. For me, the mentioned modification seems to work.
The text was updated successfully, but these errors were encountered:
I am running multiple TCS34725 sensors for some months now for environmental monitoring. I realized that the function "calculateLux" returns 65535 in some low-light-conditions:
The issue can be reproduced by calling:
The console returns:
Library-Included version of "calculateLux" function:
Proposed modification of "calculateLux" function:
Maybe there are better ways to make this function more robust. For me, the mentioned modification seems to work.
The text was updated successfully, but these errors were encountered: