TCS34725 parameters

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
User avatar
jpro56
 
Posts: 8
Joined: Thu Aug 13, 2015 5:20 pm

TCS34725 parameters

Post by jpro56 »

I want to use the TCS34725 with an Arduino UNO to functionally test some 8mm RGB LEDs with integrated WS2811.
Ideally, it would even test color consistency between LEDs and allow me to select a 'matched' subset of RGB LEDs.

I setup a small dark box with the sensor in one end a test RGB LED in the other with no other external light source.
I turn off the TCS34725 on-board white LED.

I modified the colorsensor sketch such that I drive my RGB LED with RED data from 0 to 1 to 2 to 4 etc... to 128 and repeat the same with GREEN, BLUE and then WHITE. That is my basic test. My sketch is extremely simple but giving me unexpected results.

I have changed the integrationtime and gain settings but find that the only way I get consistent results is if I add a significant delay between the tcs.getRawData(&red, &green, &blue, &clr); commands... as much as 1 or 2 seconds !?

i would definitely like to speed-up that test, Any suggestions ?
Attachments
Here's the data I get when I only have 100msec delay between tcs.getRawData
Here's the data I get when I only have 100msec delay between tcs.getRawData
TCS34725_data.PNG (28.92 KiB) Viewed 454 times

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: TCS34725 parameters

Post by Franklin97355 »

i would definitely like to speed-up that test, Any suggestions ?
Perhaps, if you post your code and a description or drawing of your connections between it all we can help. Please use the code button "</>" or

Code: Select all

 tags when posting code to the forums.

User avatar
jpro56
 
Posts: 8
Joined: Thu Aug 13, 2015 5:20 pm

Re: TCS34725 parameters

Post by jpro56 »

Here's the sketch...

#include <Wire.h>
#include "Adafruit_TCS34725.h"
#include <Adafruit_NeoPixel.h>

#define NUM_LEDS 1 // Data pin that led data will be written out over
#define DATA_PIN 8 // Clock pin only needed for SPI based chipsets when not using hardware SPI

Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_60X);

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, DATA_PIN, NEO_RGB + NEO_KHZ800);

void setup() {
Serial.begin(9600);
Serial.println("Color View Test!");

if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1); // halt!
}

tcs.setInterrupt(true); // turn off LED

pixels.begin(); // This initializes the NeoPixel library.

}


void loop() {

Serial.print("RED: ");
Serial.println();

int i = 0;
pixels.setPixelColor(0, pixels.Color(i,0,0));
pixels.show();
sense(i);

for (i=1; i<=255; i = i<<1){
pixels.setPixelColor(0, pixels.Color(i,0,0));
pixels.show();
sense(i);
}

i = 255;
pixels.setPixelColor(0, pixels.Color(i,0,0));
pixels.show();
sense(i);

Serial.print("GREEN: ");
Serial.println();

i = 0;
pixels.setPixelColor(0, pixels.Color(0,i,0));
pixels.show();
sense(i);

for (i=1; i<=255; i = i<<1){
pixels.setPixelColor(0, pixels.Color(0,i,0));
pixels.show();
sense(i);
}

i = 255;
pixels.setPixelColor(0, pixels.Color(0,i,0));
pixels.show();
sense(i);

Serial.print("BLUE: ");
Serial.println();

i = 0;
pixels.setPixelColor(0, pixels.Color(0,0,i));
pixels.show();
sense(i);

for (i=1; i<=255; i = i<<1){
pixels.setPixelColor(0, pixels.Color(0,0,i));
pixels.show();
sense(i);
}

i = 255;
pixels.setPixelColor(0, pixels.Color(0,0,i));
pixels.show();
sense(i);

Serial.print("WHITE: ");
Serial.println();

i = 0;
pixels.setPixelColor(0, pixels.Color(i,i,i));
pixels.show();
sense(i);

for (i=1; i<=255; i = i<<1){
pixels.setPixelColor(0, pixels.Color(i,i,i));
pixels.show();
sense(i);
}

i = 255;
pixels.setPixelColor(0, pixels.Color(i,i,i));
pixels.show();
sense(i);

}

void sense(int i){

delay(100);
uint16_t clr, red, green, blue;

tcs.getRawData(&red, &green, &blue, &clr);

Serial.print("I: "); Serial.print(i);
Serial.print("\tC: "); Serial.print(clr);
Serial.print("\tR: "); Serial.print(red);
Serial.print("\tG: "); Serial.print(green);
Serial.print("\tB: "); Serial.print(blue);
Serial.println();


}

User avatar
jpro56
 
Posts: 8
Joined: Thu Aug 13, 2015 5:20 pm

Re: TCS34725 parameters

Post by jpro56 »

and here's a few pictures of my setup...
Attachments
sensor setup
sensor setup
WIN_20150813_20_20_13_Pro.jpg (91.49 KiB) Viewed 438 times
sensor setup
sensor setup
WIN_20150813_20_19_45_Pro.jpg (85.97 KiB) Viewed 438 times

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: TCS34725 parameters

Post by Franklin97355 »

You might try reducing the delay(100) to a smaller number as your loop takes 1.7 minutes because of that alone.

User avatar
jpro56
 
Posts: 8
Joined: Thu Aug 13, 2015 5:20 pm

Re: TCS34725 parameters

Post by jpro56 »

The problem I get when reducing that time is with wrong readings from the sensor.

If you look at the listing in my initial post when the main loop just went through red at max brightness (255), all 3 LEDS are turned off and I get a almost the same value from the sensor as if it was still red at max brightness (255) !?!?

Looks like data was still being latched from sensor !?!? That is the problem.,

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

Return to “Other Arduino products from Adafruit”