TCS34725 — color sensor initialization (tcs34725_init)¶
What it does: Initializes the I2C color sensor TCS34725 (RGBC) with IR filter and sets the exposure time via parameter exposure.

Inputs¶
exposure: exposure time/integration parameter used by the library.scl: I2C SCL pin.sda: I2C SDA pin.- Field
rgb_id: sensor instance identifier.
Output¶
- None (statement block).
When to use it¶
- Once at program start before reading colors.
- When you need to distinguish the colors of objects at a short distance.
Tips and pitfalls¶
- TCS34725 is a color sensor with IR blocking and a very wide dynamic range.
- With this sensor, the lighting of the scene is very important. Stable white illumination is ideal.
- Changing to
exposureincreases sensitivity, but also response time.
Usage example¶

Generated Python example¶
from machine import Pin, SoftI2C
import tcs34725
if not "i2c_22_21" in globals():
i2c_22_21 = SoftI2C(scl=Pin(22), sda=Pin(21), freq=400000)
rgb_sensor1 = tcs34725.TCS34725(i2c_22_21, 10)