메이커 Maker

color sensor tcs34725 컬러 인식 모듈

지구빵집 2021. 10. 17. 17:52
반응형

 

 

강아지 공놀이 로봇 '놀아주개' 03. TCS34725 컬러 인식 모듈 

 

RGB 컬러 센서란 색상을 감지하는 센서입니다. CCD(Charge-Coupled Device)를 이용해 빛을 전하로 변환시켜 물체의 색을 감지할 수 있는 센서입니다. 색을 붉은색, 녹색, 파란색으로 표현할 수 있는 RGB를 사용해 나타 냅니다. 

 

https://m.blog.naver.com/eduino/221065374276

 

디지털카메라에 사진을 저장할 때, 물약의 색을 감지하여 어떤 물약인 지판 별할 때, 그리고 물체의 색을 감지 및 출력하는 펜을 만들 때 등색을 감지하는 역할을 하는 센서를 RGB 색깔 감지센서라고 합니다. 

 

컬러 감지 센서를 사용하기 위해 Adafruit_TCS34725 라이브러리를 설치합니다. 아두이노IDE에서라이브러리를검색하여설치가가능하며, 아래 설치 방법으로 확인할 수 있습니다.

 

아두이노 IDE - 스케치 - 라이브러리 포함하기 - 라이브러리 관리 출처: https://m.blog.naver.com/eduino/221065374276

 

TCS34725 검색하여 최신 라이브러리 설치

  

 

TCS3472 모듈은 적색, 녹색, 청색(RGB) 및 선명한 광 감지 값의 디지털 반환을 제공합니다. 온칩에 통합되고 색상 감지 포토다이오드에 국한된 IR 차단 필터는 들어오는 빛의 IR 스펙트럼 성분을 최소화하고 색상을 정확하게 측정할 수 있도록 합니다.

TCS3472는 고감도, 넓은 동적 범위 및 IR 차단 필터를 통해 다양한 조명 조건 및 감쇠 재료를 통해 사용하기에 이상적인 컬러 센서 솔루션입니다. 이 데이터는 I2C 인터페이스를 통해 호스트로 전송됩니다. 

 

 

아두이노와 TCS34725 이미지 http://arduinolearning.com/code/arduino-tcs34725-color-sensor.php

 

 

다음은 읽어 온 색깔 센서값을 씨리얼 모니터로 출력하는 예제 코드입니다.

 

#include <Wire.h>
#include "Adafruit_TCS34725.h"
 
/* Example code for the Adafruit TCS34725 breakout library */
 
/* Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground */
 
/* Initialise with default values (int time = 2.4ms, gain = 1x) */
// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
 
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
 
void setup(void) {
	Serial.begin(9600);
 
	if (tcs.begin()) {
		Serial.println("Found sensor");
	} 
    else 
    {
		Serial.println("No TCS34725 found ... check your connections");
		while (1);
	}
	// Now we're ready to get readings!
}
 
void loop(void) 
{
	uint16_t r, g, b, c, colorTemp, lux;
 
	tcs.getRawData(&r, &g, &b, &c);
	colorTemp = tcs.calculateColorTemperature(r, g, b);
	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.print(" ");
	Serial.println(" ");
}

 

씨리얼 모니터로 볼 수 있는 출력 결과는 아래와 같습니다.

 

Color Temp: 4554 K – Lux: 379 – R: 1122 G: 831 B: 776 C: 1429
Color Temp: 3173 K – Lux: 181 – R: 475 G: 339 B: 272 C: 707
Color Temp: 3425 K – Lux: 224 – R: 604 G: 435 B: 364 C: 868
Color Temp: 2833 K – Lux: 1497 – R: 2983 G: 2240 B: 1461 C: 5723
Color Temp: 5847 K – Lux: 109 – R: 4109 G: 1327 B: 890 C: 5814
Color Temp: 2767 K – Lux: 460 – R: 4468 G: 1703 B: 1062 C: 6734
Color Temp: 4381 K – Lux: 463 – R: 1379 G: 1012 B: 938 C: 1789
Color Temp: 4276 K – Lux: 588 – R: 1464 G: 1136 B: 997 C: 2153
Color Temp: 3952 K – Lux: 646 – R: 1424 G: 1135 B: 933 C: 2350
Color Temp: 3528 K – Lux: 835 – R: 1713 G: 1362 B: 1036 C: 3101

 

데이터 시트를 올립니다. 참고하세요.

 

TCS34725.pdf
0.23MB

 

참고

nRF52 - TWI 이용 TCS34725 RGB 색상 검출 센서 제어 

TCS34725 이용 원두 색상 측정 테스트 

 

 

다음 문서를 참고하세요. Calculating Color Temperature and Illuminance using the TAOS TCS3414CS Digital Color Sensor

 

Calculating Color Temperature and Illuminance using the TAOS TCS3414CS Digital Color Sensor.pdf
0.32MB

 

 

 

 

 

반응형