iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
You can detect colour with a Raspberry Pi using either a dedicated sensor or a camera. For a close-up target and a straightforward build, start with a colour sensor: a TCS3200 connects through GPIO, while a TCS34725 uses I2C and has a documented CircuitPython library. A camera is better suited to analysing a larger scene, but it requires image-processing code. In either case, readings depend on the light reaching the sensor or camera, so plan for consistent illumination and calibrate against your actual targets.
Choose a sensor for a nearby target or a camera for a scene
| Approach | Connection and workflow | Best suited to | Key considerations |
|---|---|---|---|
| TCS3200 colour sensor | GPIO; the sensor outputs a frequency affected by detected colour and light intensity. Python can inspect readings or classify colours. | Close-up colour sensing and simple primary-colour demonstrations. | Confirm your module’s pin mapping and electrical compatibility; keep target distance and lighting consistent, then calibrate. |
| TCS34725 colour sensor | I2C; Adafruit’s CircuitPython library provides RGB, clear-channel, lux and colour-temperature readings. | Projects that benefit from an I2C sensor and a documented Python API. | Check I2C setup, module voltage and logic compatibility, and how gain and integration time affect readings. |
| Raspberry Pi camera | Capture images, then use image-processing code to classify pixels or regions. | Scenes, larger areas or targets where a camera’s view is useful. | Choose a compatible camera and cable; account for illumination, white balance and the extra image-processing work. |
The Raspberry Pi’s TCS3200 tutorial describes an 8×8 photodiode array beneath red, green, blue or clear filters. Light reflected from an object changes the sensor’s output. The TCS34725 offers a different route: its CircuitPython documentation covers Raspberry Pi-compatible GNU/Linux systems and an I2C workflow.
Neither route produces a context-free colour label. A sensor measures light reflected from an object, and a camera records an image shaped by lighting and capture settings. The sources cited here do not establish a controlled accuracy comparison, universal detection range or accuracy percentage for these approaches.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Use a TCS34725 with CircuitPython
The TCS34725 is a practical choice if you want an I2C sensor with a documented Python API. Adafruit’s current library documentation describes installation on supported GNU/Linux systems, including Raspberry Pi. It also provides example code that initializes the default I2C bus and reads colour data.
#1 Best Overall
- High-Definition video camera for Raspberry Pi Model A or B, B+, model 2, Raspberry Pi 3,3 B+, Pi 4, Pi 5(NOT for Pi Zero)
- 5MPixel sensor with Omnivision OV5647 sensor in a fixed-focus lens. Software auto focus lens: B07SN8GYGD
- Integral IR filter
- Still picture resolution: 2592 x 1944; Max video resolution: 1080p
- Check ASIN: B07RWCGX5K for OV5647 with acrylic case. Other optional accessories: ABS case (B09TNG4V55); Mini tripod case kit (B09TKYXZFG).
- Connect the breakout. Wire its I2C power, ground, clock and data connections to your Raspberry Pi. Check the breakout’s voltage and logic compatibility and the pinout for your particular board before powering it.
- Install the library. In a terminal on a supported GNU/Linux system, run
pip3 install adafruit-circuitpython-tcs34725. The library introduction documents supported systems and installation. - Read the sensor. The documented example initializes the I2C bus with
board.I2C(), creates aadafruit_tcs34725.TCS34725(i2c)sensor object, then readssensor.colorandsensor.color_rgb_bytes. The API also exposes lux and colour temperature. - Inspect the channels under your project’s conditions. Compare repeated readings for your actual target colours and lighting before deciding how to classify them.
The API reference describes raw red, green, blue and clear (RGBC) channels as four 16-bit values; the RGB byte property gives red, green and blue values from 0 to 255. Gain and integration time are configurable, so record those settings when comparing readings. The simple test example demonstrates reading the sensor.
An older Adafruit Python repository for this sensor is explicitly marked deprecated and directs users to the CircuitPython sensor libraries. For a new project, use the current library documentation rather than treating the archived repository as maintained: Adafruit’s archived TCS34725 repository.
Rank #2
- How to use: Before using this hq camera, please modify the config.txt file by adding dtoverlay=IMX477 (If connect to cam0 port on Pi5, add dtoverlay=IMX477,cam0);
- For all Raspberry Pi: This Arducam for Raspberry Pi camera is compatible with all Raspberry Pi;
- What you will get: 1 x Pi hq camera(with a 1/4" tripod adapter), 1 x dust cover, 1 x C-CS adapter, 1 x 15-22pin Pi camera cable, 1 x 15-15pin Pi camera cable;
- High resolution: This camera module can offer high-resolution images with its 12.3MP IMX477 sensor, the max resolution is 4056*3040 pixels.
- Wide Application: This RPI camera can be used as a 3D printer camera, or home security monitor and can serve for Artificial Intelligence, like facial recognition, high-speed capturing, and so on.
Use a TCS3200 for GPIO-based colour sensing
The TCS3200 approach follows the Raspberry Pi tutorial: connect a TCS3200 module to GPIO and use Python to inspect its output. The sensor’s output frequency responds to the detected colour and light intensity, allowing a program to read raw values or demonstrate classification of primary colours. Consult the Raspberry Pi tutorial for its example and wiring context.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Modules can differ, so verify the pin labels and wiring for the specific board you have rather than assuming every TCS3200 breakout uses the same layout. Check electrical compatibility with your Pi before connecting it. Keep the object at a repeatable distance and avoid changing the light source between calibration and use.
Rank #3
- What Will You Get: An 8mp Arducam for Raspberry Pi camera V2 with a 15cm original FFC cable for model A and B and a 15cm FPC cable for pi zero & w.
- Sensor: 8 megapixel IMX219, Max. resolution: 3280 (H) x 2464 (V)
- Frame Rates: 1080p47, 1640 × 1232p41 and 640 × 480p206
- Recommended Power Supply: DC 5V, above 1.8A
- Typical Usage Scenarios: this tiny camera board can be used for monitoring Octoprint 3D Printer, Home security and surveillance, dashcam or other machine vision application. Please search ASIN: B09TNG4V55/B09TKYXZFG to get Arducam for Raspberry Pi Camera ABS Case and Tripod Case Kit.
Use a camera when the target is part of a larger scene
A camera can capture more than the small area directly in front of a dedicated sensor, but it does not classify colours automatically. Your program must capture an image and decide which pixels or region to analyse; the result will also depend on lighting and camera settings such as white balance.
Choose the camera and cable for your particular Raspberry Pi. Raspberry Pi’s camera documentation explains that connector requirements differ: Pi 5 and Pi Zero boards use different camera-cable requirements from flagship models through Pi 4. Check the documentation for your board before buying or connecting a camera.
Rank #4
- Pi compatible - Work natively with all Raspberry Pi models for your new project or drop-in replacement
- Both cables - 2 cables included so you can switch between the camera connectors for the Pi Zero and Model A&B series
- Specs - 5MP 1080P OV5647, crisp photos, and sharp videos with a decent frame rate
- Easy to use – Easy setup with paper instructions to help you activate the camera feature on Raspbian.
- Application: Small form factor for a tiny home video security system, monitoring 3D printer or other camera projects. Feel free to contact Arducam if you need any help with the product
Calibrate readings for your lighting and target
Set up the measurement so that changes in the reading are more likely to reflect the target rather than changing conditions. These are practical steps, not a guarantee of a particular accuracy:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →- Fix the sensor-to-object distance and angle, or use a camera position that stays constant.
- Use steady lighting. Shield the measurement area from changing ambient light where practical.
- Collect repeated raw readings from representative examples of each target colour under the conditions in which the project will operate.
- Keep sensor settings such as TCS34725 gain and integration time consistent when gathering comparison samples.
- Choose classification thresholds from those samples, rather than assuming one set of RGB values works for every object or light source.
- Allow for uncertain readings. If a sample falls between your calibrated ranges, report it as ambiguous or unknown instead of forcing a colour label.
These sensors report reflected light, and the camera approach depends on captured image data. The cited material does not provide universal thresholds or a controlled accuracy benchmark, so a reliable classification rule must be established for the project’s own setup.
Check the breakout and accessories before building
A TCS34725 breakout is one option for the I2C approach. The cited Pimoroni listing describes a board with RGB and clear sensing, an IR filter, an onboard white LED and I2C address 0x29. Product stock, package contents and board details can change; check the current listing and the specific board’s electrical requirements before ordering.
For a TCS3200 prototype, a breadboard and jumper wires may be useful, depending on how the sensor module is supplied and how you plan to connect it. A camera build needs a compatible camera module and cable. Confirm what is included with any part you choose rather than assuming accessories come in the package.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

