TCS34725 Color Recognition Sensor
This module is based on the AMS TCS3472XFN color light-to-digital converter and provides digital outputs for red, green, blue (RGB), and clear light sensing values. The sensor integrates an infrared-blocking filter to minimize the infrared light spectrum components in the incident light, allowing for accurate color measurement. It offers high sensitivity, a wide dynamic range, and an infrared-blocking filter. This minimizes the effects of IR and UV spectral components to produce accurate color measurements. The module also includes ambient light intensity detection and can shield interrupts. It communicates via an I2C interface. The design is based on the same principle but provides two different form factors (square version/dual-hole version), offering users more installation size and environmental choices. The dual-hole version also features two LEDs to provide supplementary lighting for objects.
Module Source
Purchase Link:
https://detail.tmall.com/item.htm?_u=52t4uge5c554&id=662903315676&spm=a1z09.2.0.0.47582e8dxs1caw
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1z_5qOfe-YMbj0TYSbDD-sQ?pwd=6668
Password: 6668
Specifications
Operating Voltage:3.3-5V
Operating Current: 2.5~330uA
Output Method: IIC
Pin Count: 7 Pins
Hardware Interface
- Connect the VCC pin of the TCS34725 to the 3.3V output of the development board.
- Connect the GND pin to the GND pin of the development board.
- Connect the SDA pin to the A4 pin (SDA) of the development board.
- Connect the SCL pin to the A5 pin (SCL) of the development board.
Usage Method
Install Library
The communication between the development board and the TCS34725 is done through I2C. Adafruit provides convenient libraries for the TCS34725 sensor. You need to install the Adafruit_TCS34725 library and the Adafruit_Unified_Sensor library through the Arduino IDE's library manager.
Installation Steps:
- Open the Arduino IDE.
- Go to Tools > Manage Libraries...
- In the search bar, type "Adafruit TCS34725" and install the library.
- Similarly, search for and install the "Adafruit Unified Sensor" library.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 10, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <Wire.h>
#include "Adafruit_TCS34725.h"
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
void setup() {
Serial.begin(9600);
//Serial.println("Color View Test!");
if (tcs.begin()) {
//Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1); // halt!
}
}
void loop() {
float red, green, blue;
delay(60);
tcs.getRGB(&red, &green, &blue);
Serial.print("R:\t"); Serial.print(int(red));
Serial.print("\tG:\t"); Serial.print(int(green));
Serial.print("\tB:\t"); Serial.print(int(blue));
Serial.print("\n");
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Usage Testing
When green is detected: