

The TCS3200 Waveshare is a color sensor module designed to detect and measure the intensity of red, green, blue, and clear light. It is based on the TCS3200 programmable color light-to-frequency converter. The module features an array of photodiodes with red, green, blue, and clear filters, along with an integrated frequency-to-voltage converter. The output is a square wave with a frequency proportional to the intensity of the detected light.








The TCS3200 Waveshare module has a 6-pin interface. Below is the pinout:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (2.7V to 5.5V). Connect to the 5V pin of your microcontroller. |
| 2 | GND | Ground connection. Connect to the ground of your circuit. |
| 3 | S0 | Output frequency scaling selection pin (see usage instructions). |
| 4 | S1 | Output frequency scaling selection pin (see usage instructions). |
| 5 | S2 | Photodiode filter selection pin (see usage instructions). |
| 6 | S3 | Photodiode filter selection pin (see usage instructions). |
| 7 | OUT | Frequency output pin. Connect to a digital input pin of your microcontroller. |
Below is an example Arduino sketch to read RGB values from the TCS3200 Waveshare module:
// Pin definitions
#define S0 7 // Frequency scaling pin S0
#define S1 6 // Frequency scaling pin S1
#define S2 5 // Color filter selection pin S2
#define S3 4 // Color filter selection pin S3
#define OUT 3 // Frequency output pin
void setup() {
// Set pin modes
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OUT, INPUT);
// Set frequency scaling to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int redFrequency, greenFrequency, blueFrequency;
// Select red filter
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
redFrequency = pulseIn(OUT, LOW); // Measure frequency for red light
// Select green filter
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
greenFrequency = pulseIn(OUT, LOW); // Measure frequency for green light
// Select blue filter
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
blueFrequency = pulseIn(OUT, LOW); // Measure frequency for blue light
// Print RGB values
Serial.print("Red: ");
Serial.print(redFrequency);
Serial.print(" Green: ");
Serial.print(greenFrequency);
Serial.print(" Blue: ");
Serial.println(blueFrequency);
delay(500); // Wait for 500ms before the next reading
}
No Output Signal:
Inconsistent Readings:
Output Frequency Too High or Low:
Incorrect Color Detection:
Q: Can the TCS3200 Waveshare detect colors in complete darkness?
A: No, the sensor requires a light source to detect colors. Use an external LED for illumination if needed.
Q: How do I calibrate the sensor?
A: Measure the frequency output for known colors and use these values as reference points in your code.
Q: Can I use the TCS3200 with a 3.3V microcontroller?
A: Yes, the TCS3200 operates at 2.7V to 5.5V, making it compatible with 3.3V systems. Ensure proper voltage levels for logic pins.