Library Reference

 

Construction and Initialization:


Adafruit_TCS34725(tcs34725IntegrationTime_t = TCS34725_INTEGRATIONTIME_2_4MS,

tcs34725Gain_t = TCS34725_GAIN_1X);
 
Declare a TCS34725 sensor with optional integration time and gain values.

boolean Adafruit_TCS34725::begin(void)

Initialize the TCS34725 Color Sensor. Call this function before anything else.

 

Gain and Integration Time:


void Adafruit_TCS34725::setIntegrationTime(tcs34725IntegrationTime_t it)


Sets the integration time for color samples from the sensor. Longer integration times can be used for increased sensitivity at low light levels. Valid integration times are:
    • TCS34725_INTEGRATIONTIME_2_4MS = 0xFF, /**< 2.4ms */
    • TCS34725_INTEGRATIONTIME_24MS = 0xF6, /**< 24ms */
    • TCS34725_INTEGRATIONTIME_50MS = 0xEB, /**< 50ms */
    • TCS34725_INTEGRATIONTIME_101MS = 0xD5, /**< 101ms */
    • TCS34725_INTEGRATIONTIME_154MS = 0xC0, /**< 154ms */
    • TCS34725_INTEGRATIONTIME_700MS = 0x00 /**< 700ms */

void Adafruit_TCS34725::setGain(tcs34725Gain_t gain)

Sets the gain of the ADC to control the sensitivity of the sensor. Valid gain settings are:
    • TCS34725_GAIN_1X = 0x00, /**< No gain */
    • TCS34725_GAIN_4X = 0x01, /**< 2x gain */
    • TCS34725_GAIN_16X = 0x02, /**< 16x gain */
    • TCS34725_GAIN_60X = 0x03 /**< 60x gain */

Light Readings and Calculations:


void Adafruit_TCS34725::getRawData (uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c
)

Reads the raw sensor output for the Red, Green, Blue and Clear segments of the sensor.


uint16_t Adafruit_TCS34725::calculateColorTemperature(uint16_t r, uint16_t g, uint16_t b)

Calculates the color temperature from the Red, Green and Blue components.


uint16_t Adafruit_TCS34725::calculateLux(uint16_t r, uint16_t g, uint16_t b)

Calculates Lux from the Red, Green and Blue components.

 

Interrupts and LED control:


void Adafruit_TCS34725::setInterrupt(boolean i)

Sets the sensor interrupt to generate an interrupt when the detected level is within the limits (see setIntLimits() below).  The Int pin is only available on the breakout version.

The boolean parameter can be used to control the LED.  On the breakout version, you must connect the LED pin to the INT pin for LED control.
  • Passing "false" will enable the on-board led for reflected light measurement.
  • Passing "true" will turn the led off for incident light measurement.

void Adafruit_TCS34725::clearInterrupt(void)

Clears the sensor interrupt.


void Adafruit_TCS34725::setIntLimits(uint16_t low, uint16_t high)

Sets the high and low threshold levels for interrupts. For more detail on the operation of interrupts, please refer to the data sheet.
Last updated on Dec 19, 2017 Published on May 21, 2013