Skip to content
EESP32S Wiki
Documentation/Grove TCS34725 with ESP32: RGB Color Sensor Guide
PRODUCT DOCUMENTATION

Grove TCS34725 with ESP32: RGB Color Sensor Guide

Wire the Grove V2 color sensor over I2C, read RGBC counts and improve measurements with gain, integration and controlled lighting.

Updated Oct 21, 2026 · View product ↗
On this pageIdentify the V2 sensorPrepare Arduino and the libraryConnect the Grove I2C portRead RGBC countsControl light before calibrating colorTroubleshootingSoftware versions and validationDownloads and referencesRelated products
Grove TCS34725 Color Sensor — product reference photo
Product reference photo. Check the printed model, hardware revision and pin labels before wiring.

Read red, green, blue and clear-channel measurements from the Grove I2C Color Sensor V2 using an ESP32. Begin with raw counts and controlled lighting before attempting to label an object by color.

Identify the V2 sensor

This guide is for the TCS34725FN-based Grove V2 module. An older Grove color sensor or a TCS3200 frequency-output board uses a different driver and wiring. Check the PCB version and selected product rather than choosing a library solely because its name contains “color”.

Prepare Arduino and the library

Install esp32 by Espressif Systems in Arduino Boards Manager. The C3 examples use ESP32C3 Dev Module with USB CDC On Boot enabled and Serial Monitor at 115200 baud. Start with a working Arduino upload setup, then disconnect power before changing wires.

Install Adafruit TCS34725 and its Adafruit BusIO dependency. The example explicitly uses the TCS34725 class and address 0x29. It does not use the older GroveColorSensor API.

Connect the Grove I2C port

Grove signal ESP32-C3 example Purpose
VCC 3V3 3.3 V module supply for this example
GND GND Common reference
SDA GPIO6 I2C data
SCL GPIO7 I2C clock

These are GPIO numbers on the ESP32-C3 Supermini, not physical header numbers. Identify the Grove contacts from the module labels; cable color is only an aid. For another ESP32 board select free pins using its pinout and change the code. Keep I2C pull-ups at 3.3 V.

The connection is to the Grove module, not to a bare sensor IC. Leave any interrupt output unused for the first polling example. Start with one sensor on the bus; a second device at 0x29 needs isolation or a multiplexer. See the TCA9548A guide if addresses conflict.

Read RGBC counts

Upload the sketch, open Serial Monitor and move an object in front of the sensor while keeping the distance constant. The final number is the unfiltered clear channel. It helps distinguish a dark scene from weak responses in a specific color channel.

#include <Wire.h>
#include <Adafruit_TCS34725.h>
Adafruit_TCS34725 color(TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_4X);
void setup() {
  Serial.begin(115200); delay(1500);
  Wire.begin(6, 7); Wire.setClock(100000);
  if (!color.begin(TCS34725_ADDRESS, &Wire)) {
    Serial.println("TCS34725 not found. Check VCC, GND, SDA, SCL and version.");
    while (true) delay(1000);
  }
  Serial.println("R,G,B,Clear (raw counts)");
}
void loop() {
  uint16_t r, g, b, clear;
  color.getRawData(&r, &g, &b, &clear);
  Serial.printf("%u,%u,%u,%u\n", r, g, b, clear);
  delay(500);
}

Control light before calibrating color

  1. For object measurement use the module illumination as appropriate and keep the object at a repeatable distance. For a light-source test disable the module illumination using its documented switch.
  2. Record a dark reference and a white reference under the same geometry.
  3. Compare channel ratios and repeatability before defining classification thresholds.
  4. If counts approach the conversion limit, reduce gain, shorten integration or reduce the incident light.

The example uses 154 ms integration and 4× gain as a starting configuration. Raw counts are not calibrated screen RGB values or a guarantee of accurate color naming. An object can give different readings under another lamp or at another distance.

Troubleshooting

Symptom Check next
Not found at 0x29 Check V2 identification, 3.3 V supply, SDA/SCL and connector orientation.
Nearly zero counts Check lighting, object position and whether the sensor is obstructed.
Values remain very high Reduce gain or integration time, and remove excessive illumination.
Same object gives different colors Hold distance and angle fixed and repeat the white/dark references.
Another 0x29 sensor disappears Do not place two same-address devices on the same active segment.

Software versions and validation

Documentation reviewed on October 21, 2026. The included minimal sketch was compile-checked with Arduino-ESP32 3.3.0; library versions are listed below. Compilation does not replace a test on your physical module.

Adafruit TCS34725 1.4.4, Adafruit BusIO 1.17.4

Downloads and references

Download the minimal Arduino sketch (.zip)

Need help with your board?

Share the product link, hardware revision, software version and any error messages.

Contact ESP32S support →
Shop
Sidebar
Wishlist
0 items Cart
My account
Rates by ExchangeRate-API