شحن مجاني للأوردرات فوق
1000 ج
رمضان كريم
High-Accuracy Digital Color Detection with IR Filter
The TCS34725 is a digital RGB color sensor with IR blocking filter that provides precise color sensing through an I2C interface. This sensor offers better color accuracy than traditional light-to-frequency sensors by providing direct digital outputs for red, green, blue, and clear light sensing.
Key FeaturesSeparate digital outputs for red, green, blue, and clear channels
Integrated IR blocking filter for accurate color measurement
Adjustable integration time and gain
Simple connection with 3.3V or 5V microcontrollers
| Detection Range | 380nm-780nm (Visible Light Spectrum) |
|---|---|
| Resolution | 16-bit per channel (RGB and Clear) |
| Interface | I2C (0x29 default address) |
| Supply Voltage | 2.7V – 3.6V (5V tolerant I/O) |
| Current Consumption | 0.65mA (typical at 50ms integration) |
| Integration Time | 2.4ms – 614ms (programmable) |
| Gain Settings | 1x, 4x, 16x, 60x |

| Pin | Label | Description | Arduino Connection |
|---|---|---|---|
| 1 | VCC | Power (3.3V) | 3.3V |
| 2 | GND | Ground | GND |
| 3 | SCL | I2C Clock | A5 (Uno) or SCL |
| 4 | SDA | I2C Data | A4 (Uno) or SDA |
| 5 | LED | LED control (optional) | Digital pin (optional) |
| 6 | INT | Interrupt output (optional) | Digital pin (optional) |
// Basic I2C Connections: // VCC → 3.3V // GND → GND // SCL → A5 (Uno) or SCL // SDA → A4 (Uno) or SDA // Optional connections: // LED → Digital pin (to control illumination LED) // INT → Digital pin (for interrupt functionality) // Requires Adafruit TCS34725 library
// TCS34725 Color Sensor Basic Example
#include <Wire.h>
#include <Adafruit_TCS34725.h>
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
void setup() {
Serial.begin(9600);
if (!tcs.begin()) {
Serial.println("Could not find TCS34725 sensor");
while (1);
}
}
void loop() {
uint16_t r, g, b, c;
tcs.getRawData(&r, &g, &b, &c);
Serial.print("R: "); Serial.print(r);
Serial.print(" G: "); Serial.print(g);
Serial.print(" B: "); Serial.print(b);
Serial.print(" C: "); Serial.println(c);
delay(500);
}
// Calculate color temperature
uint16_t colorTemp = tcs.calculateColorTemperature(r, g, b);
Serial.print("Color Temp: "); Serial.print(colorTemp); Serial.println(" K");
// Calculate illuminance (lux)
uint16_t lux = tcs.calculateLux(r, g, b);
Serial.print("Lux: "); Serial.println(lux);
// Set interrupt thresholds
tcs.setInterrupt(true); // Enable interrupt
tcs.setIntLimits(1000, 2000); // Set low and high thresholds
// Connect INT pin to handle interrupts
// Convert RGB to hex color code
String rgbToHex(uint16_t r, uint16_t g, uint16_t b) {
char hexColor[8];
sprintf(hexColor, "#%02X%02X%02X", r>>8, g>>8, b>>8);
return String(hexColor);
}
No account yet?
Create an Account
Recent Comments