TCS34725_I2C_Color_Sensor_For_Arduino_SKU__SEN0212-DFRobot

SEN0212 Gravity: TCS34725 RGB Color Sensor For Arduino

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

Board Overview

SEN0212 Gravity: TCS34725 RGB Color Sensor For Arduino 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:

  1. I2C address: 0x29
  2. XH2.54 interface (BreadBoard Compatible) need soldering.
  3. 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

Note: The sensor should be placed above the specimen, 3 ~ 10 mm

Connection Diagram

SEN0212 Gravity: TCS34725 RGB Color Sensor For Arduino 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

SEN0212 Gravity: TCS34725 RGB Color Sensor For Arduino 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.

More Documents