adafruit / Adafruit_TCS34725

Arduino library driver for Adafruit's TCS34725 RGB Color Sensor Breakout
http://www.adafruit.com/products/1334
Other
151 stars 151 forks source link

Issues with accuracy and speed #15

Open mkudlacek opened 7 years ago

mkudlacek commented 7 years ago

Hello, I think there is a problem with how the getRawData() works and thus affecting the accuracy of the measurement.

The getRawData() first pulls data from the sensor and then waits for some time based on integration time. So far, it seems ok, but imagine this scenario

Because of the short time between illuminating the object and taking the measurment, the actual data we will get will be before the illumination, thus R: 0 G: 0 B: 0 C:0. Next getRawData() call will return the correct values.

I propose to switch the delay and reading. First wait for the integration time, then read the values.

Moreover, the waiting is hardcoded, so the getRawData() is a blocking function. For example, I'm reading values from multiple sensors connected to I2C multiplexer. I illuminate the object, then read values from each sensor. The time to do this is NUMBER_OF_SENSORS x INTEGRATION_TIME. It would be more suitable to:

  1. illuminate
  2. wait the integration time
  3. read immediatelly current values from each sensor

    I can implement this, but please give me some response first.

ladyada commented 7 years ago

sure please try it out and submit a pull request :)