![](http://en.stamssolution.com/wp-content/uploads/2022/02/TCS3430.png)
AMS TCS3430(arduino/STM32)
Preface
This device features advanced ambient light sensing (ALS) and CIE 1931 tri-stimulus color control (and C light sensing). Each device channel has filters to allow for accurate measurement of the ambient environment, and to measure the color of the environment based on optical characteristics. These are used to calculate chromaticity, illuminance, and color temperature, all of which support various potential applications.
DFRobot_TCS3430 |
|
![]() | ![]() |
Connection layout
![](http://en.stamssolution.com/wp-content/uploads/2022/02/2022-02-18-100719.png)
- Please note that this board operates at 3.3V, not 5V, and the I2C pins on the sensor board include resistors. If using a soldered circuit board, remember to add additional resistors for proper operation.
Coding Flow
![](http://en.stamssolution.com/wp-content/uploads/2022/02/2022-02-18-100719-1.png)
- Before starting sensing, the memory inside the TCS3430 must be reset to avoid causing errors in the I2C write command.
The Sensor Initialization
bool begin()
{ uint8_t x=0x00,y=0x00;
// _pWire->begin();
softReset();
printf("softreset finish nr");
setPowerALSADC();
printf("setPower finish nr");
x=read_register(0x92);//ID=0xDC
y=read_register(0x91);//ID=0x41
if((x!=TCS3430_ID) || (y != TCS3430_REVISION_ID)){
printf("DeviceID=%#x ,RevisionID=%#x nr",x,y);
disableALSADC();
powerOFF();
return false;
}
return true;
}
Initialization table
![](http://en.stamssolution.com/wp-content/uploads/2022/02/2022-02-18-100719-2.png)
初始化完成後即可抓取Data
XData = getXData();
YData = getYData();
ZData = getZData();
IR1Data = getIR1Data();
IR2Data = getIR2Data();
printf("X :%d Y :%d Z :%d IR1 :%d IR2 :%d;nr",XData,YData,ZData,IR1Data,IR2Data);
HAL_Delay(500);
Functions included in the library such as getXData() are listed as follows and so on.
uint16_t getXData()
{
return read_register(eRegCH3DATALAddr);
}
Additional Settings
setWaitTimer
/setALSGain/setHighGAIN
The different Gain settings mainly affect the sensitivity of the device. They can be adjusted to make it more sensitive. The Wait time is mainly used for power-saving and determines the detection time interval.
Calibration and Lux/CCT Calculations
Please refer to the standard Excel provided by the AMS official website to allow the color sensor to return to the reference value through calibration.
![](http://en.stamssolution.com/wp-content/uploads/2022/02/image.png)