Electronics

Color Recognition Sensor Module TCS3200

AED 35.00

1

Description

  • The Color Recognition Sensor Module TCS3200 Black PCB is a sensor that can detect colors and provide a readout of individual RGB color components as a digital frequency. It uses a TAOS TCS3200 RGB sensor chip to detect color and contains four white LEDs that light up the object in front of it
  • The sensor has an array of photodiodes with four different filters, and a photodiode is a semiconductor device that converts light into current. The sensor can be connected directly with a microcontroller and can be used for color recognition projects such as color matching, color sorting, and test strip reading. The sensor can detect non-luminous object color and has anti-light interference.

Principle of Work:

  • White light is made up of three primary colors (Red, green and blue), which have different wavelengths. These colors combine with each other to form different shades of colors.
  • When white light falls on any surface, some wavelengths of light are absorbed and some are reflected, depending on the properties of the surface material. The color we see is a result of which wavelengths are reflected back into our eyes.
  • Now coming back to the sensor, a typical color sensor includes a high-intensity white LED that projects a modulated light onto the object. To detect the color of reflected light, almost all the color sensors consists of a grid of color-sensitive filter, also known as ‘Bayer Filter‘ and an array of photodiodes underneath.
  • At the heart of the sensor, you can find the TS3200 Color Sensor IC, this is very inexpensive and easy to use, designed and developed by TAOS (Texas Advanced Optoelectronic Solutions Inc). There are also four white LEDs, these LEDs light up when the module powers on. These LEDs light up the object that the sensor needs to sense. Other than that, there is a filter capacitor, a decoupling capacitor and some resistors onboard. The operating voltage of this module is 2.7V to 5.5V.
  • A single pixel is made up of 4 filters, one red, one blue, one green and one clear filter (no filter). This pattern is also known as the ‘Bayer Pattern‘. Each filter passes light of just a single color to the photodiode beneath, while the clear filter passes light as it is, as shown below. This extra light passed through the clear filter is a major advantage in low light conditions.
  • The processing chip then addresses each photodiode (one color at a time), and measures the intensity of the light. As there is an array of photodiodes, the results are first averaged and then sent out for processing. By measuring the relative level of red, green and blue light, the color of the object is determined. If you look closely at the sensor, you can actually see these filters.

Features:

  • High-Resolution Conversion of Light Intensity to Frequency
  • Programmable Color and Full-Scale Output Frequency
  • Power Down Feature
  • Communicates Directly to Microcontroller/Arduino
  • TCS3200 is an upgraded version of TCS230
  • Nonlinearity Error Typically 0.2% at 50 kHz
  • Stable 200 ppm/°C Temperature Coefficient
  • Low-Profile Lead (Pb) Free and RoHS Compliant Surface-Mount Package
  • Optimum Distance to Detected Object around 1cm

Specification:

  • Power Supply: 3.3 or 5V
  • Operating Voltage: 2.7 ~ 5.5V
  • Output Frequency Voltage: 0 - 5V
  • Distance Range: 10 to 15mm
  • Dimension: 32 x 25 mm
  • Weight: Approx 5g

Applications:

  • Color tracking: The sensor can be used to track and identify specific colors in a scene, such as for color-based object detection and tracking in robotics or automation applications.
  • Lighting control: The sensor can be used to measure and adjust the color temperature and intensity of lighting in different environments, such as for automatic control of stage lighting, or to create ambient lighting effects in home or commercial settings.
  • Color sorting: The sensor can be used to sort objects by color in manufacturing and packaging applications, such as for sorting candy or other small items by color.
  • Product inspection: The sensor can be used to inspect for color variations and defects in products, such as for quality control in textile manufacturing or for checking the color consistency of printed materials.
  • Robotics: The sensor can be used for color detection in robotic applications like line following, obstacle detection, etc.
  • Interactive installations: TCS3200 could be used in interactive installations where color recognition is a key component
  • Ambient lighting: The sensor can be used to match the color of ambient lighting to that of the surrounding environment.
  • Educational: TCS3200 also could be used in educational projects or experiments teaching students about color recognition and sensor usage

Pin Connections:

Pin Description
S0 and S1 The S0 and S1 pins can be used to select the Output Frequency Scaling Percentage of the sensor. By configuring these pins, it can be set to 2%, 20%, or 100% scaling.
S2 and S3 The S2 & S3 pins can be used to select the color array of the sensor. By selecting the right color array one after the other, this sensor identifies a color.
OE Output Enable (If held low, the output of the sensor is turned on)
GND This is the ground pin of the Color Sensor module and should be connected to the ground pin of the Arduino.
OUT This is the output pin of the sensor. When a particular color is detected by the sensor, the output pulse frequency on this pin changes. By detecting this change in pulse width, we can determine the color.
VCC This is the power supply pin of the color sensor that can be connected to 5V or 3.3V of the supply.

Package Includes:

  • 1 x TCS3200 Color Sensor Module

Sample Project:

Circuit:

Now that we have completely understood how a TCS3200 color Sensor works, we can connect all the required wires to Arduino and write the code to get all the data out from the sensor. The Connection Diagram of the TCS3200 with Arduino is shown below

Screen Shot 2023-01-11 at 2 22 33 PM

Connecting the TCS3200 sensor with the Arduino is very simple. To communicate with the sensor we don't need anything other than five GPIO pins of the Arduino, and that is why we have used GPIO 8,7,6,5,4 pins of the Arduino. Finally, to power the sensor we have used the 5V and Ground pins of the Arduino Board.

Library:

  • No external library is required for this module to work.

Code:

The code to process data from the TCS3200 Sensor is very simple and easy to understand. We just need to define the pins through which the sensor is connected with the Arduino. Once we do that, we will set the different modes of the sensor as mentioned in the datasheet of the device. If everything works correctly the sensor will output the color data in the form of pulses. We will use the pulsein() function of the Arduino to measure the pulse duration and determine the colors.

  • Code:
    /*
      Sensor Pin S0 -> Arduino Pin D8
      Sensor Pin S1 -> Arduino Pin D7
      Sensor Pin S2 -> Arduino Pin D6
      Sensor Pin S3 -> Arduino Pin D5
      Sensor Pin OUT -> Arduino Pin D4
    */
    #define S0_PIN 5
    #define S1_PIN 4
    #define S2_PIN 7
    #define S3_PIN 6
    #define OUT_PIN  8
    void setup()
    {
      // Set the S0, S1, S2, S3 Pins as Output
      pinMode(S0_PIN, OUTPUT);
      pinMode(S1_PIN, OUTPUT);
      pinMode(S2_PIN, OUTPUT);
      pinMode(S3_PIN, OUTPUT);
      //Set OUT_PIN as Input
      pinMode(OUT_PIN, INPUT);
      // Set Pulse Width scaling to 20%
      digitalWrite(S0_PIN, HIGH);
      digitalWrite(S1_PIN, LOW);
      // Enabl UART for Debugging
      Serial.begin(9600);
    }
    void loop()
    {
      int r, g, b;
      r = process_red_value();
      delay(200);
      g = process_green_value();
      delay(200);
      b = process_blue_value();
      delay(200);
      Serial.print("r = ");
      Serial.print(r);
      Serial.print(" ");
      Serial.print("g = ");
      Serial.print(g);
      Serial.print(" ");
      Serial.print("b = ");
      Serial.print(b);
      Serial.print(" ");
      Serial.println();
      if (r < 42)
      {
          Serial.println("Colour Pink");
      }
      else if (g < 63)
      {
          Serial.println("Colour Green");
      }
      else if (r < 64)
      {
          Serial.println("Colour Red");
      }
    }
    int process_red_value()
    {
      digitalWrite(S2_PIN, LOW);
      digitalWrite(S3_PIN, LOW);
      int pulse_length = pulseIn(OUT_PIN, LOW);
      return pulse_length;
    }
    int process_green_value()
    {
      digitalWrite(S2_PIN, HIGH);
      digitalWrite(S3_PIN, HIGH);
      int pulse_length = pulseIn(OUT_PIN, LOW);
      return pulse_length;
    }
    int process_blue_value()
    {
      digitalWrite(S2_PIN, LOW);
      digitalWrite(S3_PIN, HIGH);
      int pulse_length = pulseIn(OUT_PIN, LOW);
      return pulse_length;
    }
    

Troubleshooting:

TCS3200 Color Sensor not Working? Here is what you should do:

  1. If you are having trouble reading the TCS3200 sensor, please first check the operating voltage of the device. The stable operating voltage of this device is 2.7V to 5.5V. Driving the sensor with any other voltage values will make the sensor unstable.
  2. If you are having fluctuations in the reading try covering up the sensor with a box. This will keep the distance of the sensor constant and also it will reduce the outside noise.
  3. If you are having scaling issues, please check the S0 and S1 pins of the sensor if they are configured correctly.
  4. If you are having issues with the output, please make sure that the S2 and S3 pins are configured properly.

Commonly Asked Questions about Color Sensor TCS3200

1. What does a color sensor detect?

A color sensor can detect the received light intensity for red, blue, and green respectively, making it possible to determine the color of the target object.

2. How many pins are there in the color sensor?

It consists of color filters, photodiode array, current to frequency converter and final square wave output which can be given directly to a microcontroller. The TSC3200 Color Sensor IC is an 8 pin IC with SoC(System on a Chip) package. The following image shows the pin diagram of the Colou Sensor IC.

3. Do color sensors work in the dark?

Yes, it can work in the dark because it has four white bright LEDs. The color sensor can distinguish between colors or measure the intensity of the reflected light, making it ideal for line following. By emitting its own light, the sensor can work even in absolute darkness to determine the color or brightness of the surface.

4. What are the main parts of a color sensor?

Color sensors contain a white light emitter to illuminate the surface. Three filters with wavelength sensitivities at 580 nm, 540 nm, and 450nm to measure the wavelengths of red, green and blue colors respectively.

Notes:

  • There exists much colour aberration during module testing, so if you have any special need for color testing, pay attention to it.
  • Pins S0 and S1 are used for scaling the output frequency. Take a look at the table below.

    282499259-0b53614c-7dc5-4f4d-9e57-8a6548c565b5

  • Pins S2 and S3 are used to select one of the 4 photodiode types. Take a look at the table below.

    282499178-6e5280d1-070e-4816-b226-220125d25016

References: