Hello, I have a color issue with the TCS34725. I used the code given with it :
include "Adafruit_TCS34725.h"
/* Example code for the Adafruit TCS34725 breakout library */
/* Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground */
/* Initialise with default values (int time = 2.4ms, gain = 1x) */
// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
void setup(void) {
Serial.begin(9600);
if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1);
}
// Now we're ready to get readings!
}
void loop(void) {
uint16_t r, g, b, c, colorTemp, lux;
int Teinte;
String Couleur;
tcs.getRawData(&r, &g, &b, &c);
colorTemp = tcs.calculateColorTemperature(r, g, b);
lux = tcs.calculateLux(r, g, b);
Teinte=getTeinte(r, g, b);
Serial.print("H : "); Serial.print(Teinte, DEC); Serial.print(" ");
Serial.println("");
AfficheCouleur(Teinte);
/Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
Serial.print("Teinte: "); Serial.print(Teinte, DEC); Serial.print(" ");
Serial.println(" ");/
delay(5000);
}
float getTeinte(uint16_t pr, uint16_t pg, uint16_t pb)
{
int H;
float r= (float)pr/255;
float g= (float)pg/255;
float b= (float)pb/255;
float Cmax = Max(r, g, b);
Serial.print("r: "); Serial.print(r,2); Serial.print(" ");
Serial.print("g: "); Serial.print(g,2); Serial.print(" ");
Serial.print("b: "); Serial.print(b,2); Serial.print(" ");
Serial.print("Cmax: "); Serial.print(Cmax,2); Serial.print(" ");
float Cmin = Min(r, g, b);
Serial.print("Cmin: "); Serial.print(Cmin,2); Serial.print(" ");
float Delta = Cmax - Cmin;
Serial.print("Delta: "); Serial.print(Delta,2); Serial.print(" ");
Serial.println("");
H= getH(r, g, b, Cmax, Delta);
return H;
}
float Min(float pr, float pg, float pb)
{
if(pr<pg && pr<pb)
return pr ;
else if(pg<pb && pg<pr)
return pg ;
else
return pb ;
}
float Max(float pr, float pg, float pb)
{
if(pr>pg && pr>pb)
return pr ;
else if(pg>pb && pg>pr)
return pg ;
else
return pb ;
}
int getH(float pr, float pg, float pb, float pCmax, float pDelta)
{
int Temp;
if(pDelta==0)
return 0;
else if(pCmax==pr)
{
Temp= 60_((pg-pb)/pDelta);
Temp= Temp%6;
}
else if(pCmax==pg)
Temp= 60_(((pb-pr)/pDelta)+2);
else
Temp= 60*(((pr-pg)/pDelta)+4);
return Temp;
}
But the pH is always below what it need to be, if I put yellow on the captor, the pH will be between 1 and 5. If I put black, the pH is green. I have this problem on 2 drivers.