这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » 试用TCS34725颜色识别模块

共1条 1/1 1 跳转至

试用TCS34725颜色识别模块

专家
2025-10-14 13:18:16   被打赏 10 分(兑奖)     打赏

一、模块介绍

TCS34725是一款低成本颜色识别传感器模块。其工作原理是,通过照明LED发光,照射到被测物体后,返回光经过滤镜检测RGB的比例值,根据RGB的比例值识别出颜色。模块使用IIC接口,可以进行简单的7种颜色识别,不需要计算RGB值。

图片4.png


二、工作参数

图片1.png


三、原理图

图片2.png

四、引脚说明

图片3.png

说明:最少接线只需要使用Vin、GND、SCL、SDA即可。

四、示例程序(Arduino平台)


#include <Wire.h>
#include "Adafruit_TCS34725.h"
/* Example code for the Adafruit TCS34725 breakout library */
// TCS34725          ESP8266
// =================================
// LED               GND(板载LED不亮) 或者 悬空(板载LED亮)
// SCL               D1
// SDA               D2
// Vin               3.3V
// GND               GND
/* 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_614MS, TCS34725_GAIN_1X);
void setup(void) {
  Serial.begin(115200);
  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);
  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.print(" ");
  Serial.println(" ");
}


注:程序需要安装Adafruit TCS34725支持库

上传程序后测试,在点亮LED场合,测试西瓜霜的黄色包装,测试结果:

图片5.png

红色和绿色的分量值比较高,蓝色的比较低,能匹配黄色的预期结果。




关键词: 大懒猫的试用笔记     TCS47325     颜色识别模块    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]