The TCS3472 device provides a digital return of red, green, blue (RGB), and clear light sensing values. An IR blocking filter, integrated on-chip and localized to the color sensing photodiodes, minimizes the IR spectral component of the incoming light and allows color measurements to be made accurately. The high sensitivity, wide dynamic range, and IR blocking filter make the TCS3472 an ideal color sensor solution for use under varying lighting conditions and through attenuating materials.
Pin Number | Name | Description |
---|---|---|
1 | VDD | Power supply (2.7V to 3.6V) |
2 | GND | Ground reference for power supply |
3 | SCL | Serial clock for I2C communication |
4 | SDA | Serial data for I2C communication |
5 | INT | Interrupt output |
6 | LED | Control for external LED |
7 | OE | Output enable (active low) |
#include <Wire.h>
#include "Adafruit_TCS34725.h"
// Create an instance of the TCS34725 sensor
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
void setup() {
Serial.begin(9600);
Wire.begin();
if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS3472 found ... check your connections");
while (1); // halt!
}
}
void loop() {
uint16_t r, g, b, c, colorTemp, lux;
tcs.getRawData(&r, &g, &b, &c);
colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
lux = tcs.calculateLux(r, g, b);
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.println(" ");
delay(1000);
}
Q: Can the TCS3472 be used with a 5V system? A: The TCS3472 is a 3.3V device, but it can be interfaced with a 5V system using level shifters for the I2C lines.
Q: How can I adjust the integration time and gain?
A: The integration time and gain can be adjusted using the provided library functions, such as tcs.setIntegrationTime()
and tcs.setGain()
.
Q: What is the purpose of the external LED pin? A: The LED pin can be used to drive an external light source, which can be useful for providing consistent lighting conditions for color sensing.
Q: How do I calibrate the sensor for accurate color measurements? A: Calibration involves taking readings under known lighting conditions and adjusting the readings or the environment until the sensor outputs the expected values. This process can be done manually or with the help of calibration software.