Arduino Spectrophotometer




Introduction: Arduino Spectrophotometer

About: I'm a health care professional, amateur astronomer, author and occasional car and motorcycle mechanic.

I'm an amateur astronomer tasked with giving an educational talk to fellow amateur astronomers about how to clean optical surfaces like the lenses of eyepieces and telescopes. I wanted to run a small experiment cleaning some uniform glass samples (that had been coated with dust and mineral deposits) with a variety of commercial and homemade cleaning solutions. But how to quantify the efficacy of the cleaning process?

I decided I could run the glass samples before and after the cleaning process through a spectrophotometer and compare transmission profiles. And one can buy a used student spectrophotometer these days on eBay for a ridiculously low price .... but we all have way too much stuff that we buy, use once and then stash away.

The solution would be to build an Arduino Spectrophotometer, a simple one that did not involve the complex mechanics of a rotating prism (or diffraction grating) and optical slit to deliver monochromatic light to the sample.

Step 1: Materials

Arduino UNO

RGB led

light dependent resistor (photocell)

3 270 ohm resistors

2 10k ohm resistors


push button switch

Step 2: Schematic Circuit Diagram

The build is extremely simple because the wavelength of visible light being emitted is entirely digitally controlled by the RGB led. By altering the pulse width modulation values form the UNO to the RGB led you can deliver the primary red, green, blue colors and all the intermediary colors. I tried to keep the level of illumination constant by making the sum of all RGB outputs to a value of 210.

Step 3: Arduino Sketch

The Arduino Sketch is also similarly simple. An array stores all the needed PWM values to deliver the range of visible light from red to blue. The data is output in a CSV compatible form for capture in either a Terminal program to import into Excel or simply cut and pasted directly into Excel from the Arduino Serial Monitor screen.

I've glued the RGB led and photocell in opposite ends of a rectangular piece of polycarbonate plastic. There is a hole drilled between the led and photocell that crosses a slit I cut where my glass samples can be inserted for testing. In the attached image, I placed some translucent red tape folded over a few times to increase opacity into that slot and ran the spectrophotometer. A plastic cover made from black PVC plumbing components is important to allow the spectrophotometer to operate in the dark.

Step 4: Red Tape Results

You can see that the transmission profile for just air decreases in the blue part of the spectrum which is expected because typical cadmium sulphide photocells are less sensitive in the blue region.

The transmission profile of the red tape has been normalized to correct for the less sensitive blue region and clearly demonstrates how well this spectrophotometer works!

Be the First to Share


    • New Year, New Skill Student Design Challenge

      New Year, New Skill Student Design Challenge
    • Anything Goes Contest 2021

      Anything Goes Contest 2021
    • Raspberry Pi Contest

      Raspberry Pi Contest



    Question 3 years ago

    Hi, very nice project! I am doing something similar with a LED+driver integrated circuit (basically I just give the values for 0 to 255 to each of the RGB components and it lights up of the corresponding shade). I'd like to know how you calculate the wavelengths corresponding to the various RGB mixed components, so I can try do something like that too.

    Thank you very much!


    Question 3 years ago on Step 1

    Hello. Can I get the coding for this project.


    Answer 3 years ago

    The sketch is downloadable from the site, look for it!


    6 years ago

    This is a neat project. I could see it being an effective way to look at efficacy of various cleaning techniques.

    A few points:

    - The use of an RGB LED means that you can't really do measurements across the whole visible spectrum. Really you'd only be able to do effective measurements within about ~25nm of the R, G, and B wavelengths (typically around 625nm, 525nm, 460nm). There may be a small amount of light outside those ranges but your SNR of the measurement would be much worse. You might consider adding additional LEDs to your setup with colors in between RGB. Look up the RGB LED light spectrum on Google Images and you'll see lots of examples of what I'm talking about. Years back we spent a fair amount of time looking at using LEDs to replace halogen and mercury arc lamps as light sources for solar cells testing. But ultimately the incomplete/uneven spectrum of LED sources was unacceptable given the quality of measurement we required.

    - Related to my above comment, 5nm steps in your spectrum is probably not realistic given the FWHM of the LEDs is on the order of 25nm. You might consider a smaller step size.

    - I noticed there's a periodicity to your measurements which I suspect is related to the 5nm step size you're using and how you're calculating your intensity. I'd have to spend some more time looking at it to figure out exactly what's going on there.

    - The fall time of a typical CdS photocell is about 20ms, whereas the typical PWM period for a 490Hz wave is (~2ms). This means that you should probably wait about 20ms before taking a measurement (you wait 50, which is good). If the fall time were shorter you might get concerned about whether your photocell was getting constant measurements (ie: does it "see" the PWM wave, or an average level).

    - calibrating this setup would be good. unfortunately without a reference photometer or source it would be difficult. you might look at some more advanced light/RGB sensors which may come with more reliable reference spectra. Thankfully LEDs and photocells are fairly reliable in their output/sensitivity over normal time scales so drift shouldn't be too much of an issue.

    Ultimately, for spectrometry one can either determine the measured wavelength at the source (often done with diffraction grating or filters, but here you use an LED) or at the detector (again a diffraction grating, filters can be used). Interferometry is also used but perhaps outside the breadth of this discussion.

    The use of an RGB LED is probably your biggest limitation compared to a a "real" photometer. If you were to switch to a series of LEDs with peak wavelengths about 25nm apart I think you could make a relatively competitive photometer. The more extreme version seen in advanced research environments is using a broadly tunable laser to achieve very narrow spectral resolution (<1nm) over a few hundred nm range.

    That being said for what you are trying to do, I bet you could get plenty of good info just from transmission of blue, green and red light. At the very least you could get some measurement of the amount of "junk" on your glass surface. In my experience while some applications call of very high spectral resolution (such as for characterizing lasers), many are just fine with >10-20nm resolution. In fact when working on solar cells we often see clear indicators just by looking at "blue" and "red" wavelengths. I'd just be careful if you're trying to draw any strong conclusions about the chemical make-up of what is on your surface from this data as I don't think the resolution or range will be adequate.

    So how did your measurements turn out? Would be curious to see what kind of conclusions you were able to draw.


    Reply 6 years ago

    I meant to say you should have *larger than 5nm steps for your resolution. Not smaller.


    Reply 5 years ago

    Very educative post!
    I know nothing about spectrophotometers and their uses, and now I do.
    I hope jim_chung can take your points into account in further versions of his device :D


    6 years ago

    Thanks, and all valid points to be sure! This projects definitely is not meant to replace a true spectrophotometer.