Introduction
The TCS34725 I2C arduino color sensor has a high sensitivity, wide dynamic range, and includes an IR blocking filter making it an ideal color sensing solution for use under varied lighting conditions. The TCS34725 color sensor also includes four ultra-bright LEDs to allow the sensor to work without external light resources. The module works via your Arduino’s I2C bus and includes PH2.0-4P and XH2.54 (breadboard) interfaces to meet a range of user scenarios.
Specification
- Operating Voltage: 3.3~5V
- Operating Current: 65 uA
- Detection Range: 3-10 mm
- The Clock Frequency: 0-400 KHZ
- Interface: IIC interface
- IIC Address: 0x29
- Temperature Range: - 30 ℃ ~ + 70 ℃
- Feet inches: 18.5 * 23 mm/ 0.73 * 0.9 inches
- Weight: 12 g
Board Overview
Num | Label | Description |
---|---|---|
1 | SDA | I2C-SDA |
2 | SCL | I2C-SCL |
3 | VCC | 3.3~5V |
4 | GND | GND |
5 | LED | Active-High/Vacant On |
6 | INT | Active Low |
Note:
- I2C address: 0x29
- XH2.54 interface (BreadBoard Compatible) need soldering.
- The paper of the blocking filter could be teared out.
Tutorial
In this tutorial, we'll detect the specimen RGB value, and simulate it with RGB LEDs
Requirements
Hardware
- DFRduino UNO (or similar) x 1
- RGB LED Module
- M-M/F-M/F-F Jumper wires
Software
- Arduino IDE (Version requirements: V1.6.x), [https://www.arduino.cc/en/software| Click to Download Arduino IDE from Arduino®]
Note: The sensor should be placed above the specimen, 3 ~ 10 mm
Connection Diagram
Sample Code
Install the Arduino Library Download here. How to install Libraries in Arduino IDE
/*!
* @file colorview.ino
* @brief Gets the ambient light color
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author PengKaixing(kaixing.peng@dfrobot.com)
* @version V1.0.0
* @date 2022-03-16
* @url https://github.com/DFRobot/DFRobot_TCS
*/
#include "DFRobot_TCS34725.h"
DFRobot_TCS34725 tcs = DFRobot_TCS34725(&Wire, TCS34725_ADDRESS,TCS34725_INTEGRATIONTIME_24MS, TCS34725_GAIN_1X);
void setup()
{
Serial.begin(115200);
Serial.println("Color View Test!");
while(tcs.begin() != 0)
{
Serial.println("No TCS34725 found ... check your connections");
delay(1000);
}
}
void loop() {
uint16_t clear, red, green, blue;
tcs.getRGBC(&red, &green, &blue, &clear);
tcs.lock();
Serial.print("C:\t"); Serial.print(clear);
Serial.print("\tR:\t"); Serial.print(red);
Serial.print("\tG:\t"); Serial.print(green);
Serial.print("\tB:\t"); Serial.print(blue);
Serial.println("\t");
// Figure out some basic hex code for visualization
uint32_t sum = clear;
float r, g, b;
r = red; r /= sum;
g = green; g /= sum;
b = blue; b /= sum;
r *= 256; g *= 256; b *= 256;
Serial.print("\t");
Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);
Serial.println();
}
Expected Results
FAQ
Q&A | Some general Arduino Problems/FAQ/Tips |
---|---|
A | For any questions, advice or cool ideas to share, please visit the DFRobot Forum. |