TCS34725 Color Temperature Problems! Please help!

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Trstn12
 
Posts: 4
Joined: Fri Feb 07, 2014 6:23 pm

TCS34725 Color Temperature Problems! Please help!

Post by Trstn12 »

Hello adafruit community! I'm working with the TCS34725 color sensor paired with the adafruit TCS34725 library and example code which outputs RGB values, lux, and color temperature. The library and example code work perfectly for one light source I have which, when measured with a professional chroma meter reads 2695K, and reads 2600K on the TCS. A little inaccuracy isn't a problem. However, when I switch to the other light source which reads 6490K on the professional chroma meter, the TCS reads over 11,000K. Randomly, however, the TCS sometimes reads the 6500K accurately, but then the 2700K source is off by 1000K and reads closer to 1600K. Is there any way to make this more accurate? It's not a linear problem (i.e. I can't just make a subtraction to calibrate the sensor, it's exponentially different.) I'm not very experienced in this type of sensor and am sort of at a loss of where to start improving the code.

Thank you!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: TCS34725 Color Temperature Problems! Please help!

Post by adafruit_support_mike »

It sounds like you may have a problem with the connections. Could you post a photo of your hardware please? The forum has a limit on file size, but 800x600 images usually hit the sweet spot between amount of visible detail and loadability.

Trstn12
 
Posts: 4
Joined: Fri Feb 07, 2014 6:23 pm

Re: TCS34725 Color Temperature Problems! Please help!

Post by Trstn12 »

Thank you for your response! Here's a picture of my setup. The color sensor shows up just fine and like I said reads the lower end color temps correctly. My next question is within the library, the RGB value mappings were done based on a 6500K fluorescent, 3000K fluorescent and an incandescent bulb. I'm measuring LEDs. Fluorescent bulbs tend to be much heavier in Green than LEDs, could this be where the problem is? It would seem to make sense the warmer color temperature would read more accurately on the TCS because you have the incandescent in there which are usually 2700K and have a wider spectrum just like my lower CCT LEDs. The higher CCT LEDs have a wider more even spectrum than the higher temperature fluorescent bulbs so it seems to make sense why the higher CCT lamp isn't reading correctly. Here is the excerpt from the .cpp file I'm curious about. My question is, do you think this is a probable cause to the problem and if so, how to I measure new values with the LEDs? Through a light meter or off of raw data on the TCS, etc? What is F in this instance? Thank you very much!!

/* 1. Map RGB values to their XYZ counterparts. */
/* Based on 6500K fluorescent, 3000K fluorescent */
/* and 60W incandescent values for a wide range. */
/* Note: Y = Illuminance or lux */
X = (-0.14282F * r) + (1.54924F * g) + (-0.95641F * b);
Y = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
Z = (-0.68202F * r) + (0.77073F * g) + ( 0.56332F * b);

/* 2. Calculate the chromaticity co-ordinates */
xc = (X) / (X + Y + Z);
yc = (Y) / (X + Y + Z);

/* 3. Use McCamy's formula to determine the CCT */
n = (xc - 0.3320F) / (0.1858F - yc);

/* Calculate the final CCT */
cct = (449.0F * powf(n, 3)) + (3525.0F * powf(n, 2)) + (6823.3F * n) + 5520.33F;

/* Return the results in degrees Kelvin */
return (uint16_t)cct;
}
Attachments
20140210_094336.jpg
20140210_094336.jpg (150.09 KiB) Viewed 1770 times

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Color Temperature Problems! Please help!

Post by adafruit_support_bill »

The problem here is that neither sensor nor light sources are ideal :?. Color temperature is based on the concept of a blackbody emittter which will put out a continuous spectrum. http://en.wikipedia.org/wiki/Black-body_radiation

The sensor is a composite device with sensitivities in 3 bands in the red, blue and green parts of the spectrum. The color temperature calculation assumes that it is sampling parts of a continuous spectrum and that the energy between the bands is distributed as in an ideal emitter.

Sunlight and Incandescent lights are reasonable approximations of black body emitters and color temperature calculations on these can be reliably made. "White" LEDs and Flourescent spectra are discontinuous with some nasty peaks: http://en.wikipedia.org/wiki/File:Fluor ... belled.svg They use UV radiation to excite phosphors which emit light in very narrow frequency bands. The color temperature calculation can be skewed depending on how those peaks match up with the sensitivity bands of your sensor. If the sensitivity bands of the TCS34725 are not exactly the same as your chroma meter, they are likely to come up with very different results.

Trstn12
 
Posts: 4
Joined: Fri Feb 07, 2014 6:23 pm

Re: TCS34725 Color Temperature Problems! Please help!

Post by Trstn12 »

Thank you for your help! So at this point, is there either another sensor you would recommend, or, better yet, how can I calibrate this sensor to match more closely to my chroma meter which is reading much more accurately? The LEDs I'm using do have a color rendering index (90+) closer to that of a black body curve than your average LEDs. How can I get the coefficient the .cpp already uses for my LED's specific values?

It is mapped to the X, Y, and Z counterparts of the three light sources, but I'm confused, what are those mappings? What do those numbers represent? There is the X Y and Z of three light sources, but how do you know which to multiply by r, g, and b? I suppose I'm more confused about how to take my readings on my chroma meter and translate them to new values for r,g,b on the X,Y,Z portion. Do you have any ideas?

Thank you again!

Trstn12
 
Posts: 4
Joined: Fri Feb 07, 2014 6:23 pm

Re: TCS34725 Color Temperature Problems! Please help!

Post by Trstn12 »

Now that I think of it I should rephrase my question. to calculate the X,Y, and Z chromacity coordinates I'm pretty sure it's a matter of doing X/X+Y+Z, Y/X+Y+Z, and Z/X+Y+Z, is that correct? With that I can now get the chromatic coordinates for the three light sources.

Still the confusion lies with where these coordinates go? When I look at the library file, X, Y, and Z each have only one value for R, G, and B, which r,g,b values go with which light source? Is there a more in depth explanation for that one section of the .cpp file? Any way to comment next to the individual values to show what they represent? Thank you!

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Color Temperature Problems! Please help!

Post by adafruit_support_bill »

The algorithm is from McCamy and the calculations are described in detail in this article:

http://onlinelibrary.wiley.com/doi/10.1 ... 1/abstract

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”