Skip to the content
2 layers86.4 × 61 mmRgb pcb, the printed circuit board in 3D

An embedded color-detection device built on the STM32F103C8T6 microcontroller. It scans the color of a surface using a TCS34725 sensor and displays the relative Red, Green, and Blue intensities — along with a bar chart…

Size
86.4 × 61 mm
Copper layers
2
Thickness
1.6 mm
Parts
19
Nets
45
Pads
85
Tracks, vias
188, 16
Pours
8
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
5 Mar 2026
Updated
21 Jun 2026

Overview

Rgb pcb is an open-source printed circuit board by marcravel, from the marcravel/RGB_bildiren repository on GitHub. It is a 2-layer board of 86.4 × 61 mm with 19 parts on 45 nets, routed with 188 tracks and 16 vias.

It is built around the L7805. Its parts include 5 capacitors, 4 resistors, 4 connectors, 2 diodes and 2 switches. It belongs with the lEDs and displays boards of this library.

Main components

1

README

README.md

RGB Color Meter (RGB_bildiren)

An embedded color-detection device built on the STM32F103C8T6 microcontroller. It scans the color of a surface using a TCS34725 sensor and displays the relative Red, Green, and Blue intensities — along with a bar chart and the dominant color — on an SSD1306 OLED screen.


Table of Contents


Overview

This project provides a portable tool for scanning surface colors and identifying the dominant primary color (Red, Green, or Blue). It combines a microcontroller, a digital color sensor, and an OLED display into a simple, self-contained measurement device — useful for basic color categorization and detection tasks, with results reported visually in real time.


System Architecture

The device is made up of three subsystems: power supply, microcontroller firmware, and sensor/display I/O.

mermaid
graph TD
    BT1[9V Battery Cell] -->|Raw Power| SW1[SPDT Power Switch]
    SW1 -->|Switched V| D1[1N4007 Protection Diode]
    D1 -->|Input V| U1[L7805 Linear Regulator]
    U1 -->|Regulated +5V| J1[STM32 Blue Pill Board 5V Input]
    J1 -->|On-board 3.3V LDO| V33[+3.3V Net]

    V33 -->|Power| TCS[TCS34725 Color Sensor]
    V33 -->|Power| OLED[SSD1306 OLED Display]

    MCU[STM32F103C8T6 MCU] <-->|I2C2 PB10/SCL, PB11/SDA| TCS
    MCU <-->|I2C2 PB10/SCL, PB11/SDA| OLED

    SW2[Push Button] -->|PA8 Input| MCU
    MCU -->|PA7 Output| LED[White Illumination LED]

Data Flow

  1. Triggering – The MCU continuously polls a push button (PA8, internal pull-up). A debounced press starts the scan state machine.

  2. Illumination – The MCU drives a white LED on PA7 to provide consistent lighting on the target surface.

  3. Acquisition – Over the I2C2 bus (PB10/SCL, PB11/SDA), the MCU commands the TCS34725 to integrate RGBC light values. For 3 seconds it polls the sensor's status register (AVALID) and reads all 8 bytes of color data in a single burst transaction.

  4. Processing – Raw counts are accumulated and averaged over the 3-second window to reduce flicker noise, then normalized:

    text
    normalized = (color × 255) / (Red + Green + Blue)

    The channel with the highest percentage is reported as the dominant color.

  5. Display – Bars, raw values, and the dominant color label are rendered on the SSD1306 OLED over I2C2.


Tech Stack

Hardware & PCB

ComponentDetails
MCUSTM32F103C8T6 — ARM Cortex-M3, 72 MHz, 64 KB Flash, 20 KB SRAM
Color SensorTCS34725 (I2C address 0x29)
DisplaySSD1306, 128×64 monochrome OLED (I2C address 0x3C)
PowerL7805 linear regulator + 1N4007 protection diode, with input/output smoothing capacitors
PCB CADKiCad 10.0 (rgb_pcb.kicad_sch, rgb_pcb.kicad_pcb)

Firmware

ComponentDetails
LanguageC (C99)
ToolchainSTM32CubeIDE, arm-none-eabi-gcc
HALSTM32F1xx HAL Library v1.8.7
Pin ConfigSTM32CubeMX (RGB_bildiren.ioc)
OLED DriverCustom SSD1306 driver (ssd1306.c / ssd1306.h)

Hardware Requirements

  • STM32F103C8T6 development board ("Blue Pill")
  • TCS34725 RGB color sensor module
  • SSD1306 OLED display module (I2C, 128×64)
  • ST-Link V2 programmer (SWD)
  • Misc: momentary push button, SPDT switch, 9V battery, L7805 regulator, 1N4007 diode, 220 Ω / 4.7 kΩ resistors, standard capacitors

Software Requirements

  • STM32CubeIDE v1.10.0 or later
  • KiCad v6.0 or later (for viewing/editing schematics and PCB layout)

Build Instructions

  1. Open STM32CubeIDE.
  2. Go to File → Import... → General → Existing Projects into Workspace.
  3. Select the repository root folder as the import directory.
  4. Click Finish.
  5. Select the project in the Project Explorer and press the Build (hammer) icon, or Ctrl+B. Output files are generated under Debug/.

Flashing the Firmware

  1. Wire the ST-Link V2 to the Blue Pill's SWD pins:

    ST-LinkBlue Pill
    GNDGND
    SWCLKPA14 (DCLK)
    SWDIOPA13 (DIO)
    3.3V3.3V
  2. Connect the ST-Link to your computer via USB.

  3. In STM32CubeIDE, right-click the project → Run As → STM32 Cortex-M C/C++ Application.

  4. The build will be flashed as RGB_bildiren.elf onto the MCU.


Key Features

  • 3-second integration averaging — accumulates Clear/Red/Green/Blue samples over 3 seconds to smooth out flicker and lighting noise.
  • Auto-increment burst read — all 8 color data bytes are read in one I2C transaction:
    c
    HAL_I2C_Mem_Read(&hi2c2, TCS3472_I2C_ADDR, TCS3472_CMD_AUTO_INC | REG_CDATAL,
                      I2C_MEMADD_SIZE_8BIT, buf, 8, HAL_MAX_DELAY);
  • Power savings — the sensor's ADC (AEN bit) is disabled outside of active measurement to reduce power draw.
  • Visual progress bar — a live countdown and progress bar render on the OLED during the 3-second scan.

Project Structure

text
RGB_bildiren/
│
├── Core/
│   ├── Inc/                         # main.h, HAL config, interrupt declarations
│   └── Src/                         # main.c (state machine + sensor/UI logic), HAL MSP, ISR handlers
│
├── Debug/                           # Build output (ELF, MAP, makefile)
│
├── Drivers/
│   ├── CMSIS/                       # ARM core definitions
│   ├── STM32F1xx_HAL_Driver/        # ST HAL library
│   └── OLED/                        # SSD1306 driver, config, fonts
│
├── PCB-Schematics/
│   ├── print.pdf
│   └── rgb/
│       ├── rgb_pcb/                 # KiCad schematic + PCB layout
│       └── rgb.kicad_sch
│
├── RGB_bildiren.ioc                 # STM32CubeMX pin configuration
└── STM32F103C8TX_FLASH.ld           # Linker script

Known Limitations

  • Hardware/firmware pin mismatches:
    • Firmware reads the push button on PA8; the KiCad schematic routes it to PA12.
    • Firmware drives the illumination LED on PA7; the KiCad schematic routes it to PA10.
    • As shipped, a PCB built from the current KiCad files will not respond to the button or light the LED unless the firmware pin defines or the PCB traces are updated to match.
  • Continuous re-triggering on hold — holding the button down causes the debounce check to re-arm every cycle once past the debounce window, making it impossible to view a static result screen while holding the button.
  • No I2C error recovery — return codes from HAL_I2C_Mem_Read are not checked; a noisy or disconnected bus can hang the system via HAL_MAX_DELAY.
  • Fixed sensor calibration — integration time (24 ms) and gain (60x) are hardcoded, with no auto-calibration. This causes saturation in bright light and low resolution in dark settings.
  • Mixed-language comments — firmware comments mix English and Turkish, and the project path contains Turkish characters, which may cause encoding or path-resolution issues on some systems.

Suggested Improvements

  • Pin sync — update main.h to use PA12/PA10 (simplest fix) or re-route the PCB to use PA8/PA7.
  • Button latching — require a full release before re-arming the trigger, so one press maps to exactly one scan.
  • I2C timeout & recovery — check transfer return codes and force-reset the I2C peripheral on HAL_TIMEOUT/HAL_ERROR.
  • Auto-gain control (AGC) — dynamically lower gain on saturation (near 10240 counts at 24 ms) and raise it when readings are too low, to expand dynamic range.
  • White-point calibration — store a white-reference value in Flash and normalize readings against it instead of a raw arithmetic average, correcting for sensor spectral imbalance.

Parts

19
QtyValueFootprintReferences
2220Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR1, R4
24.7kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR2, R3
2Conn_01x20_SocketConnector_PinSocket_2.54mm:PinSocket_1x20_P2.54mm_VerticalJ1, J4
1100nFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mmC3
1100uFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mmC2
1100uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC4
110uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC5
11N4007Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD1
1220nFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mmC1
19VTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalBT1
1Conn_01x04_SocketConnector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_VerticalJ2
1Conn_01x07_SocketConnector_PinSocket_2.54mm:PinSocket_1x07_P2.54mm_VerticalJ3
1L7805Package_TO_SOT_THT:TO-220-3_VerticalU1
1LEDLED_THT:LED_D5.0mmD2
1SW_PushButton_Switch_THT:SW_PUSH_6mmSW2
1SW_SPDTConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalSW1

Similar boards

  • 2 layers40.6 × 110 mmEuropi surface mount, the printed circuit board in 3D

    Europi surface mount

    Allen-Synthesis/EuroPi

    EuroPi: A reprogrammable Eurorack module based on the Raspberry Pi Pico

    92 parts584CC0-1.0
  • 2 layers132.1 × 45.7 mmIPoS, the printed circuit board in 3D

    IPoS

    peterheinrich/InternetOverSpaghetti

    Transmitting IP packages over a pair of spaghetti thus demonstrating how media independent IP really is.

    42 parts342
  • 2 layers59.7 × 57.5 mmFunBox, the printed circuit board in 3D

    FunBox

    GuitarML/FunBox

    Stereo guitar pedal platform using Daisy Seed.

    61 parts289MIT
  • 2 layers90.8 × 35.6 mmERCF easy brd, the printed circuit board in 3D

    ERCF easy brd

    Tircown/ERCF-easy-brd

    More informations on how to reset for flashing:\ https://wiki.seeedstudio.com/Seeeduino-XIAO/#enter-bootloader-mode

    28 parts195GPL-3.0
  • 2 layers111.3 × 106.4 mmSuper Sixteen v1, the printed circuit board in 3D

    Super Sixteen v1

    matthewcieplak/super-sixteen

    Code and schematics for the Super Sixteen Eurorack sequencer

    141 parts171
  • 2 layers91.4 × 71.1 mmPico w rover, the printed circuit board in 3D

    Pico w rover

    NikodemBartnik/Mini-Mars-Rover

    Educational robotic platform made to look like a mini mars rover

    20 parts143MIT
  • 2 layers144.1 × 182.2 mmSHVC CPU-01, the printed circuit board in 3D

    SHVC CPU-01

    starlightk7/OpenSFC

    OSHW Reproduction Parts related to the Super Famicom / Super Nintendo game console

    498 parts114CERN-OHL-S-2.0
  • 2 layers106.1 × 155 mmMotherboard, the printed circuit board in 3D

    Motherboard

    Redherring32/OpenTendo-TopLoader

    An Open Source HardWare (OSHW) recreation of the 1993 toploading NES motherboard (Also known as NES-101)

    84 parts94

Questions

How big is the Rgb pcb PCB?

It measures 86.4 × 61 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Rgb pcb use?

19 parts, built around the L7805. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Rgb pcb KiCad files?

From the marcravel/RGB_bildiren repository on GitHub, at the commit this page was made from: the board is PCB-Schematics/rgb/rgb_pcb/rgb_pcb.kicad_pcb and its schematic PCB-Schematics/rgb/rgb.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Rgb pcb design in my own project?

Its repository states no licence, so its author keeps all rights: ask marcravel before reusing the design.