Code: Select all
void loop(void) {
tcs.setGain(TCS34725_GAIN_1X); // no gain
tcs.getRawData(&r, &g, &b, &c);
lux = (float)tcs.calculateLux(r, g, b)/gain;
Serial.print("Lux: "); Serial.println(lux);
delay(1000);
tcs.setGain(TCS34725_GAIN_60X); // 60x gain
tcs.getRawData(&r, &g, &b, &c);
lux = (float)tcs.calculateLux(r, g, b)/gain;
Serial.print("Lux: "); Serial.println(lux);
delay(1000);
}
If I insert the following 2 lines after each "tcs.setGain" then the readings are what one would expect:
Code: Select all
void loop(void) {
tcs.setGain(TCS34725_GAIN_1X); // no gain
tcs.getRawData(&r, &g, &b, &c);
delay(700);
tcs.getRawData(&r, &g, &b, &c);
lux = (float)tcs.calculateLux(r, g, b)/gain;
Serial.print("Lux: "); Serial.println(lux);
delay(1000);
tcs.setGain(TCS34725_GAIN_60X); // 60x gain
tcs.getRawData(&r, &g, &b, &c);
delay(700);
tcs.getRawData(&r, &g, &b, &c);
lux = (float)tcs.calculateLux(r, g, b)/gain;
Serial.print("Lux: "); Serial.println(lux);
delay(1000);
}
In looking at the TCS34725 library, I noticed that "getRawData" reads the RGBC values first, then does a delay for the Integration time. This seems backward to me - if it's going to wait, shouldn't it wait first, then fetch the data?
William