Precise measurement TCS34725

Hello, I have a sensor reading project with TCS34725, I have managed to measure and transform, but I don't know much about how I can do precess calculations for the color detection since it is wrong many times, some people tell me that by taking an average, others that with machinlearning, but I'm really lost.
have some idea what I should do?
I add my arduino code to them:

// Define global variables
MD_YX5300 mp3(ARDUINO_RX, ARDUINO_TX);

Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_1X);
 int medicion=0;

void setup()
{
  Serial.begin(9600);
  pinMode(3,INPUT); 
  mp3.begin();
 if (!tcs.begin())
  {
    Serial.println("Error al iniciar TCS34725");
    while (1) delay(1000);
  }

}

void loop()
{
  btn_color = digitalRead(3);
  Serial.print("BTN:");
  Serial.println(btn_color);
  if(btn_color){
    
   sense_color();
  delay(1000);   
  }
  
  delay(100);

  
  

}

void sense_color(){
  uint16_t clear, red, green, blue;
 
  tcs.setInterrupt(false);
  delay(60); // Cuesta 50ms capturar el color
  tcs.getRawData(&red, &green, &blue, &clear);
  tcs.setInterrupt(true);
 
  // Hacer rgb medición relativa
  uint32_t sum = clear;
  float r, g, b;
  r = red; r /= sum;
  g = green; g /= sum;
  b = blue; b /= sum;
 
  // Escalar rgb a bytes
  r *= 256; g *= 256; b *= 256;
 
  // Convertir a hue, saturation, value
  double hue, saturation, value;
  ColorConverter::RgbToHsv(static_cast<uint8_t>(r), static_cast<uint8_t>(g), static_cast<uint8_t>(b), hue, saturation, value);
 Serial.println(++medicion);
 
  // Mostrar nombre de color
  printColorName(hue * 360,saturation, value);
 Serial.println("hue: ");
 Serial.println(hue * 360);
 Serial.println("saturation: ");
 Serial.println(saturation);
 Serial.println("value: ");
 Serial.println(value);
  delay(1000);
}

my project is school, I want to help a friend who is blind to know the color of some things, to present it at the science fair.

I would like it to have a lower range of failure.

could you help me ?

@jose2396trino

Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

since it is wrong many times

Please explain the experiment that you did, and how you determined the result was "wrong".

Hi,
Can you please post a circuit diagram of you project?

Is there something missing in the code you posted?
Is the code complete?
Where is the library?
Have you tried one of the examples in the IDE to prove your connections?

Tom.... :slight_smile:

[pre]y use like : [iurl=http://www.arduinoprojects.net/sensor-projects/arduino-uno-tcs34725-color-sensor-example.php]Arduino Uno and TCS34725 Color Sensor example - Arduino Projects[/iurl] tutorial .
I used another TCS34725  sensor and the same thing happens, I am currently sure that it is not the senso but the reading code.
my teacher mentioned something to me about a gauss average but I don't understand what he means for filtering readings
[pre]​

[/pre]

[/pre]

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
https://forum.arduino.cc/index.php?topic=712198.0

It would be better if you attached your image file and let it be placed into your post.

Can you please post a circuit diagram of you project?

Is there something missing in the code you posted?
Is the code complete?
Where is the library?
Have you tried one of the examples in the IDE to prove your connections?

Thanks.. Tom.. :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.