Raspberry Pi–Based Spectrometer
Building a Compact Optical System to Measure Light
\[ \usepackage{booktabs} \]
\[ \newcommand\v[1]{\vec{#1}} \newcommand\vdot[2]{\vec{#1}\cdot\vec{#2}} \]
\[ \newcommand\f[2]{\dfrac{#1}{#2}} \newcommand\da[2]{\dfrac{d #1}{d #2}} \newcommand\daa[2]{\dfrac{d^2 #1}{d #2^2}} \newcommand\pa[2]{\dfrac{\partial #1}{\partial #2}} \newcommand\pal[3]{\left.\dfrac{\partial #1}{\partial #2}\right|_{#3}} \newcommand\paa[2]{\dfrac{\partial^2 #1}{\partial #2^2}} \newcommand\pab[3]{\dfrac{\partial^2 #1}{\partial #2 \partial #3}} \def\half{\frac{1}{2}} \]
\[ \newcommand\ket[1]{\left|#1\right\rangle} % |x> \newcommand\exp[1]{\left\langle#1\right\rangle} % <x> \newcommand\ex[1]{\left\langle#1\right\rangle} % <x> \newcommand\lr[1]{\left(#1\right)} % (x) \newcommand\lrs[1]{\left[#1\right]} % [x] %\newcommand\lrb[1]{\left|#1\right|} % |x| \newcommand\lra[1]{\left|#1\right|} % |x| \newcommand\lrc[1]{\left\{#1\right\}} % {x} \newcommand\lrl[3]{\left.#1\right|_{#2}^{#3}} % x_limits \]
\[ \def\ie{\text{i.e.}\quad} \]
$$ % Typical reaction % Nuclear reactions$$
\[ \newcommand{\coulomb}[1]{\dfrac{#1}{4\pi\epsilon_0}} \]
\[ \def\amu{\text{ amu}} \def\J{\text{ J}} \def\K{\text{ K}} \def\s{\text{ s}} \def\second{\text{ s}} \def\Psecond{\text{ s}^{-1}} \def\m{\text{ m}} \def\mm{\text{ mm}} \def\km{\text{ km}} \def\fm{\text{ fm}} \def\mum{\text{ $\mu$m}} \def\mus{\text{ $\mu$s}} \def\mPERs{\text{ ms$^{-1}$}} \def\eV{\text{ eV}} \def\keV{\text{ keV}} \def\GeV{\text{ GeV}} \def\MeV{\text{ MeV}} \def\MeVc{\text{ MeV/c$^2$}} \def\KeVc{\text{ KeV/c$^2$}} \newcommand\ttp[1]{\times 10^{#1}} % To The Power \]
$$
$$
\[ \def\uraniumA{_{92}^{233}{\text{U}}_{}} \def\uraniumB{_{92}^{235}{\text{U}}_{}} \def\uraniumC{_{92}^{238}{\text{U}}_{}} \def\carbonB{_{6}^{14}{\text{C}}_{}} \def\nitrogenB{_{7}^{14}{\text{N}}_{}} \def\oxygenA{_{8}^{14}{\text{O}}_{}} \def\oxygenB{_{8}^{16}{\text{O}}_{}} \]
\[ \def\com{\text{\scriptsize CM}} \]
\[ \def\l{\ell} \def\l{l} \]
\[ \def\g{\gamma} \def\g{\gamma} \]
$$
$$


(Source: ThorLabs)
Introduction
Spectrometry allows us to use light as a probe — to reveal the invisible structure and behavior of atoms and molecules. When light interacts with matter, it carries away a signature of that interaction: a pattern of colours or wavelengths that encodes physical information. By carefully analyzing these spectral patterns, scientists can deduce the composition, temperature, and even the motion of distant stars — or, at a much smaller scale, the concentration of chemical species in a liquid sample.
In everyday research, spectrometers are indispensable. They are used in chemistry to measure absorption spectra of solutions, in physics to study atomic transitions, and in environmental science to detect pollutants. However, commercial spectrometers are often expensive and not easily modified for exploratory work.
This project asks you to bridge that gap by designing and refining a Raspberry Pi–based spectrometer that is both accessible and scientifically meaningful. The challenge is to make something simple yet serious: an instrument that might not match the precision of a commercial system but still provides reliable, quantitative measurements when used carefully.
In doing so, you will move beyond the role of a “user” of equipment and step into the mindset of a builder and problem-solver: someone who understands how instruments work, what limits their accuracy, and how design choices shape data quality. You will engage with questions such as:
- How does the geometry of the setup affect spectral resolution?
- What optical components are truly essential, and which can be improvised?
- How can you calibrate wavelength using known emission lines?
- What are the main sources of noise and uncertainty in your measurements?
By the end of this project, you will have not just a working prototype but a deeper appreciation for the craft of scientific instrumentation: the delicate balance between theory, practicality, and ingenuity that underpins much of modern experimental science.
Project Details
Your PI wants to develop a fast, accurate, yet cost-effective capability to perform spectroscopic measurements of liquids. She has realised that it is quite feasible to build a simple but functional Raspberry Pi–based spectrometer.
To get started, she has used some remaining funds from a grant to purchase a few optical instruments from Thorlabs. More specifically, she has obtained two educational spectrometer kits (models EDU-SPEB2/M and EDU-SPEBCT1/M link) and gathered some additional components from colleagues who had spare parts lying around. Unfortunately, due to budget constraints and the short lead time to use the funds, some components are missing from the kits. A few parts were also intentionally left out — they are not essential for a system that uses a Raspberry Pi as the detector.
Your PI now needs your help to set up and test the optical system, refine the design, and establish a workflow that can be reproduced later by other researchers or students.
Your main task is to set up the optical system and obtain clear spectra from a few known light sources, (such as hydrogen (H), helium (He), and mercury (Hg) lamps).
To help you get started, you will be provided with the educational kits and some additional optical components. You are free to experiment with different optical designs and arrangements, as long as you you can justify your choices.
As you proceed, you will need to:
- Optimise your optical alignment to capture distinct spectral lines.
- Determine how best to position the slit, grating, and detector.
- Calibrate your wavelength scale using known emission lines.
- Keep detailed notes of all attempts, observations, and outcomes.
Remember: there is no single “correct” design the focus is on how you reason, iterate, and justify your decisions.
Additional Equipment: If you find that a particular component (for example, a lens or grating) is essential for your design, I can try to borrow or source it for you. However, such requests must come with a clear and specific justification in the form of an explanation what the component is for, what specifications you require, and why it is necessary for your setup to function properly.
Optical Components



| ID | Description | Quantity |
|---|---|---|
| CFI25 | Cage plate, 25 mm, for lens or mirror mounting | 5 |
| BE1M | Pedestal base adapter, M6 thread | 5 |
| TR50M | Optical post, Ø12.7 mm × 50 mm length | 3 |
| BA2 | Mounting base, 50 mm × 100 mm | 3 |
| BA1 | Mounting base, 25 mm × 75 mm | 3 |
| TR75 | Optical post, Ø12.7 mm × 75 mm length | 4 |
| PH50 | Post holder, 50 mm height | 3 |
| UPH75 | Universal post holder, 75 mm height | 2 |
| PH75 | Post holder, 75 mm height | 9 |
| ID | Description | Quantity |
|---|---|---|
| R2M | Right-angle mounting bracket | 1 |
| LMR1 | Lens mount, Ø1 inch optics | 3 |
| KMSR | Kinematic mirror mount, Ø1 inch | 2 |
| KM100 | Kinematic mirror mount, precision adjust | 2 |
| VA100M | Variable iris aperture, Ø25 mm | 2 |
| LB1676 | Bi-convex lens, f = 50 mm, Ø25.4 mm | 1 |
| LB1 | Bi-convex lens, f = 100 mm, Ø50.4 mm | 1 |
| LB1471 | Bi-convex lens, f = 100 mm, Ø25.4 mm | 2 |
Since there is only one complete spectrometer setup, all groups taking on this project will need to share the equipment.
How we organise this sharing will depend on how many groups choose this challenge. Once the numbers are clear, we’ll coordinate a schedule to ensure everyone gets fair and sufficient access.
Please be mindful that this equipment costs thousands of dollars and includes precision optical components. Handle everything with care and respect — treat it as if it were your own research instrument.
Caring for Optical Components
High-precision optical instruments are delicate and expensive. Proper care and handling are essential to maintain their performance and prevent damage. Handle optics as if they were priceless — because they are. A small scratch, fingerprint, or misplaced turn of a screw can undo hours of careful work.
How to Clean a Lens
Blow off dust to remove loose particles.
Use a clean rubber air blower to gently blow air across both sides of the lens. Aim the air at an angle rather than straight on to avoid pushing dust deeper into the surface.Brush gently to dislodge any remaining dust.
Use a soft camel-hair or optical brush to sweep debris away. Hold the lens so that particles fall off the surface, not onto it.Remove smudges or fingerprints.
Use lens tissue or lint-free wipes slightly moistened with optical cleaning solution (e.g. 70% isopropyl alcohol in water). Gently swipe from the centre outward in one smooth motion.
Avoid rubbing in circles or using excessive liquid — a minimal amount is sufficient.
When not to clean:
- If the lens is dusty and imaging is unaffected, leave it alone.
- Never clean in a dusty or humid environment.
- Avoid touching or wiping coated surfaces unless absolutely necessary.
Do’s and Don’ts for Precision Optics
✅ Do
- Hold lenses by the rim or mount, never the optical surface.
- Work on a clean bench with a soft optical mat.
- Align carefully; small adjustments are best.
- Clean only when necessary and always gently.
- Verify calibration and alignment regularly.
- Document every step and adjustment in your logbook.
❌ Don’t
- Don’t touch optics with bare fingers.
- Don’t use paper towels or rough cloths.
- Don’t blow with your mouth.
- Don’t press hard or force screws and mounts.
- Don’t leave lenses uncovered or unlabelled.
- Don’t overtighten screws — it can stress or warp the optics.
- Don’t mix solvents or cleaning fluids unless verified safe.
- Don’t adjust multiple components at once — change one variable at a time.