Skip to the content.

GY-33 Arduino Library

An easy-to-use Arduino library for the GY-33 (TCS34725) Colour Sensor module. This library is a C++ port of the MicroPython GY-33 library by QuirkyCort.
This is for connecting to the GY33’s microcontroller (typically STM32), not for direct connection to the TCS34725 color sensor.
This library supports both I2C and UART (Serial) communication modes.


Credits & Technical Documentation

This library is a C++ port of the original logic developed by QuirkyCort.

Since the GY-33 documentation is often difficult to find in English, please refer to the original repository here: micropython-gy33

Also:
UART Mode overview
UART Mode Protocol Details

I2C Mode overview
I2C Mode Protocol Details


Hardware Setup

The GY-33 can be powered by 3.3V or 5V via the VCC pin. However, the data pins are 3.3V logic level.

Note: S1 is used for direct sensor access (TCS34725) via I2C and is left open when using this library. This mode uses pins 7 and 8 (SDA and SCL). Use it with a TCS34725 library such as Adafruit TCS34725 Driver


Quick Start

1. I2C Mode

Ensure S0 is connected to GND.

#include <GY33.h>

GY33_I2C sensor;

void setup() {
  Serial.begin(115200);
  sensor.begin(); // Uses default SDA/SCL pins
}

void loop() {
  if (sensor.update()) {
    Serial.print("Colour: ");
    Serial.println(sensor.colour());
  }
  delay(500);
}

2. UART Mode

Ensure S0 is Open/High.

#include <GY33.h>

GY33_UART sensor(Serial1);

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600, SERIAL_8N1, 8, 9); // Adjust pins for your board
  sensor.begin();
}

void loop() {
  if (sensor.update()) {
    Serial.print("Colour: ");
    Serial.println(sensor.colour());
  }
  delay(500);
}