DIY Projects

DIY Handheld Spectrometer Uses a TCD1304 CCD and STM32

DIY Handheld Spectrometer Uses a TCD1304 CCD and STM32

A $20 prism cannot tell you how much protein is in a test tube, but a linear CCD sitting where the light lands can. That is the trick behind a handheld visible-light spectrometer built by the maker Curious Scientist, covered on Hackster.

What got built

Light enters through an optical fiber and hits a collimating mirror, which turns the spreading beam into parallel rays. A diffraction grating then fans the beam out by wavelength, much like Newton’s prism, and a second mirror focuses the spread onto a sensor. Where the bright spot lands along the sensor tells you the color, and how bright it is tells you the intensity. Chemistry and biology classes use exactly this idea to measure how much a reagent changed color in a sample.

Technical details

The sensor is a TCD1304, a 3648-pixel linear CCD, so only one dimension of the spectrum is captured. Version one streamed readings to a PC running custom graphing software. The portable version swaps the PC for an STM32F401CCU6 board (84 MHz Cortex-M4) that reads the CCD and draws the graph on a 4-inch SPI display. A rotary encoder changes settings and moves a cursor so you can read the exact peak at any wavelength. An 18650 cell (3.7 V) with a charging module powers it all inside a printed enclosure.

The gotcha with linear CCDs is timing. The TCD1304 needs a master clock around 2 MHz plus precisely spaced shift-gate and integration pulses, so plan on using hardware timers and DMA rather than bit-banging GPIO pins in a loop.

Build it yourself

Start small. Wire any analog light sensor to an Arduino A0 pin behind a cheap diffraction grating slide and sweep it by hand to see the idea. Then move up to a CCD and an STM32 or ESP32 once you are comfortable with timers. For a physics or chemistry capstone, a spectrometer that reads absorbance of colored solutions is a strong thesis demo. Check Arduino boards and sensors at circuit.rocks, and read the original build notes at the Hackster page.

Frequently Asked Questions

How does this spectrometer measure color?

A diffraction grating spreads incoming light by wavelength onto a TCD1304 linear CCD. The pixel position of a bright spot maps to wavelength, and its brightness gives intensity.

What parts and skills do I need?

An STM32F401 board, a TCD1304 CCD, a diffraction grating, mirrors, an SPI display, a rotary encoder and an 18650 cell. You need timer and DMA basics plus light soldering.

What will I learn if I build this?

You learn optics basics, linear CCD timing, SPI display drawing, rotary encoder input and battery power design, all useful for physics, chemistry or instrumentation theses.

This article was inspired by reporting from Hackster. Find the parts and modules to build it at Circuitrocks.

// written by Ann Arandia

Ann Arandia covers community projects and maker events for the Circuitrocks blog. She writes about local workshops, kid-friendly electronics, and the Philippine maker scene — the people, the meet-ups, the projects that come out of them.