Example Code for Arduino-Read Data
Last revision 2025/12/17
This article provides a detailed guide and example code for reading data from a TCS3430 Tristimulus Color Sensor using an Arduino. It includes hardware and software preparation, a wiring diagram, and a sample code to facilitate data acquisition, making it an ideal resource for enthusiasts and learners eager to explore sensor data interaction with Arduino.
Hardware Preparation
- DFRduino UNO R3 (or similar) x 1
- TCS3430 Tristimulus Color Sensor Breakout Board x1
- Jumper wires
Software Preparation
- Arduino IDE
- Download and install the TCS3430 Library and Sample Code. (About how to install the library?)
Wiring Diagram

Sample Code
/*!
* @file getXYZIRData.ino
* @brief Detection of XYZ tristimulus and infrared data
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [yangfeng]<[email protected]>
* @version V1.0
* @date 2021-01-26
* @get from https://www.dfrobot.com
* @url https://github.com/DFRobot/DFRobot_TCS3430
*/
#include <DFRobot_TCS3430.h>
DFRobot_TCS3430 TCS3430;
void setup() {
Serial.begin(115200);
while(!TCS3430.begin()){
Serial.println("Please check that the IIC device is properly connected");
delay(1000);
}
}
void loop() {
uint16_t XData = TCS3430.getXData();
uint16_t YData = TCS3430.getYData();
uint16_t ZData = TCS3430.getZData();
uint16_t IR1Data = TCS3430.getIR1Data();
uint16_t IR2Data = TCS3430.getIR2Data();
String str = "X : " + String(XData) + " Y : " + String(YData) + " Z : " + String(ZData) + " IR1 : "+String(IR1Data) + " IR2 : "+String(IR2Data);
Serial.println(str);
delay(1000);
}
Result

Was this article helpful?
