Student Spectrophotometer


Let me first give credit where credit is due. My inspiration for this project comes from AlfonsVH with his "A simple DIY spectrophotometer". Having said that I have made some improvements to his design and I want to share what I have learned.

Why I built it:

This project was meant for one of my professors of instrumental analysis (chemistry required coursework). He had mentioned something about cutting back on the amount of chromatography labs and having the students build their own instrument to better understand how they work. I was really excited about that idea, and even though my class at the time wouldn't have been able to try it out, I wanted to show that it was possible. That way future students could have a template. Also so that my professor would be more inspired to test out different ideas for himself.

Step 1: The Specifications

Specifications / Limitations:

  • Visible spectrum (tungsten filament a.k.a an incandescent light bulb)
  • Minimum of 15 steps (using a servo motor)
  • Lens to focus spectrum
  • external 5V power supply for servo motor (AC adapter)
  • Separate 3V power supply for light source (batteries)
  • Protoshield for easy removal from arduino

Tools / materials needed:

  • An Arduino
  • Photoresistor
  • Resistors (10K x 2, 560)
  • LED
  • Button
  • Cuvette (a.k.a the sample holder)
  • Servo motor Razor blades (the slit)
  • Hot glue
  • light source (small flashlight with incandescent bulb)
  • Stuff to solder
  • Mini lens
  • CD (the diffraction grating)
  • Patience
  • Enclosure

When it's done it should be able to:

  • Compile a spectrum in a short amount of time
  • Give averaged values
  • Provide some characterstics of the compound being studied

Step 2: What's Important to Know

The attachment

I've written and attached a summery about building your own scientific instruments with Arduino if anyone is interested. It goes into a little more detail with the project and more. I want to keep this instructable as simple as possible because I could go much further in depth, so if you want more detail check out the attachment.

Lets keep it simple

What's important from the schematic:

  1. The order and location of the photoresistor and the 10K (circled in red)
  2. The external 5V power supply

Why it's important:

  1. The order of the resistor and photoresistor is important because the order defines the voltage divider equation. We want to measure transmittance*(see theory basics) so we need the numbers in the Arduino serial monitor to be proportional to the intensity of the light.
  2. The external 5V power supply is necessary to drive the motor because if the motor and the photoresistor are on the same 5V from the Arduino the signal will be really noisy. We avoid this by having an external 5V (Note: All grounds should still be tied together).

Theory basics

Transmittance is the light that makes it through the sample (measured)
Absorbance is just that, the light absorbed by the sample (calculated using A = 2 - log(%T)

For a more in depth explanation see attachment.

Step 3: Building It

I think the pictures say it all, and what they don't the schematic will. You can choose to lay it out slightly differently but it's all the same principle. The light from the incandescent bulb hits the CD (diffraction grating) hot-glued to the servo motor. As the motor moves the different wavelengths pass through the slit (two razor blades) and through the cuvette which holds the sample and then finally to the detector (in this case the photoresistor).

The protoshield was just a little added bonus, but the design could have easily worked the same with a bread board as long as the schematic is followed exactly.

Step 4: The Code

I'm not a coder but I know how to copy and paste. I modified a code that I got online see attachment.

Brief outline of what the code does

1. Waits for button press (assumes you turned light source on)

2. Indicator LED turns on (when button is pressed)

3. Motor takes 3 big steps then takes 5 measurement

4. Motor takes 15 small steps (repeating the measurement 5 times) Note: serial monitor must be visible!

5. Light shuts off and motor goes back to "home position"


After the data is in the serial monitor it needs to be uploaded into Microsoft excel. I find that copying and pasting it first into notepad works best. Then copy again from there and paste special into excel (it will go straight into columns). Then I recommend looking up a macro for excel that averages every five measurements (google it).

Note: for each sample there needs to be a blank. The sample data must be subtracted from the blank data and then you can use A = 2 - log(%T). Make sure you understand the x-axis so that you know whether the wavelengths are going from high to low (or vice versa).

Step 5: Results

The above spectrum is an extraction of chlorophyll a, b, and carotenoids from spinach leaves. Next to it I have the actual spectrum and they surprisingly match up quite well!

Step 6: Messing Around

I also did spectra of dilute wine and bourbon. I think it would be fun if I took a bunch of spectra of different wines and whiskys and then logged the taste data next to the spectra to see if I could place what tannin went with what wavelength.

Maybe in a future experiment!

Step 7: Closing Thoughts

Improvements from AlfonsVH's design:

  • Using the Arduino to do analog readings (using a separate 5V source for motor as necessary)
  • Using a lens to focus the light into a more concise wavelengths
  • Having a somewhat portable enclosure
  • Time it takes to run a spectra is less than a minute
  • Using a protoshield for easy removal from Arduino

Improvements from my design

  • It is definitely obvious that a different type of motor could be used to get more wavelengths (the downside is of course the amount of time will greatly increase)
  • A laser and a standard could be used to calibrate which steps correspond to which wavelengths
  • Maybe varying the slit width
  • possibly taking fluorescence measurements (after some alterations)
  • A sexier enclosure

P.S. if you guys want me to do spectra of anything cool (chemical sample in solution) post a comment and I just may update the instructable!

Full Spectrum Laser Contest 2016

Participated in the
Full Spectrum Laser Contest 2016



    • Planter Challenge

      Planter Challenge
    • Sew Tough Challenge

      Sew Tough Challenge
    • Backyard Contest

      Backyard Contest

    18 Discussions


    8 months ago

    Hello I'm building a slightly improved version of this as a college project was wondering could you email me the code as I am having problems with the spectrometers code and also what stepper motor did you use


    Question 10 months ago on Step 5

    Hi, I am building a benchtop spectrophotometer with Arduino and TSL2561 luminosity sensor (photodiode based). Could you please explain a bit more in detail how you calculate absorbance? Is it simply the log of the ration between the light you get with the sample and th elight you get without it (would it be your "blank" data?)

    2 answers

    Reply 10 months ago

    Each wavelength is going to have a different amount of intensity on the detector. So for example lets say at 520 nm the intensity on the detector is some arbitrary number, say, 32 (but thats the max because theres no sample). Lets say you put a sample that absorbs light at 520 nm and when you measure again the detector at that wavelength says 16. Your transmittance is then 50% or 0.5. Now, at another wavelength lets say 700 nm your detector reads another arbitrary value 45, and when you measure a sample it then reads 15, this means your transmittance is 33% or 0.33. So in other words you need to find what the maximum intensity for a given wavelength is, and then measure your sample at that specific wavelength. Do this for all wavelengths and you have the transmittance across all wavelengths.

    Now the purpose of the blank is less to do with the instrument and more to do with subtracting out your unwanted signal. For example, let's say I have a solution of gold nanorods and I measure the absorbance at 900 nm and get and absorbance of 0.1. The only problem is that water itself (i.e. the solvent) also absorbs at that wavelength, therefore you have to subtract out that signal by measuring water by itself first, then the water + AuNRs. In other words your blank should contain everything except your analyte.


    1 year ago

    how did you get the light intensity(lux)? what formula did you use? i tested mine and got 3.48 voltage output with a 1.26V power source and 2k resistors, can and how do i convert this to light intensity?

    3 replies

    Reply 1 year ago

    First I measured a value for a blank (note: it came out as an integer value on the serial monitor in the range 0-1023), next I measured the value for my sample and got a similar but, of course, smaller value (because some of the light was absorbed by the sample). Since the transmittance is defined as the incoming intensity divided by the maximum (in this case the max is the blank) I used T = I(sample) / I(blank). Note once again, the values I was getting for I(sample) and I(blank) were integer values. So as an example, for a specific wavelength I might have gotten 600(sample)/1000(blank) or T = 0.6. From there I calculated the absorbance using the Beer-Lambert law.

    As you can see I never directly measured the value for the Intensity of the sample or the blank (at least not in SI units) instead I only needed the ratio of my sample to the blank to calculate the transmittance. Had I known the SI unit conversion based on my apparatus, the result still would have been the same, I still would have had to divide the incoming intensity by the maximum--only it would be in different units; but the ratio still would have been the same.


    Reply 1 year ago

    i was wondering, how do you know the wavelength that you are measuring? i can see that i am measuring using the red side of the spectrum but how do i know what wavelength(in nm) it is
    any equations i could use?


    Reply 1 year ago

    The short answer is you don't.

    You would need to calibrate it somehow, either by using a well known sample that gives you a predefined spectrum and then match your points to the wavelengths. It's not worth trying to get the wavelengths unless you get the steps of the motor to be very very small.


    2 years ago



    3 years ago

    Hi thanks for the project its really cool . I have a question can we use this spectrophotometer to study water quality for presence of ammonia , ph , dissolved oxygen etc ?


    1 reply

    Reply 3 years ago

    For this specific instrument: only methods using the visible spectrum will work. That means if you are trying to build a similar instrument to say detect ammonia then you should search for a methodology for doing this in the visible spectrum. Now if you are only ever going to use the instrument for one (or a few) types of molecules then you might simplify the design by finding wavelengths where these molecules have a high peak in the visible spectrum and use specific LEDs that only have most of their intensity around those wavelengths (also they make LEDs in many wavelengths, so you are not restricted to visible). If you use this latter method then you can omit the diffraction grating (CD), light bulb, and motor. I'm not sure if ammonia or oxygen exhibit wavelengths in the visible (definitely check their IR and also what IR LEDs are available) but maybe you can find a paper where these molecules complex with a chemical to make a wavelength which can be detected by the instrument. Or who knows maybe you will find a better method. If you're trying to do quantitative analysis you need to take into consideration the limit of detection of your instrument (depending on how accurate you actually want to be). Finally, with pH you're better off buying a pH meter or making your own using arduino. If your knowledge of chemistry isn't very good I'd be happy to clear up anything I can, but your question is very broad so I can't really give you a yes or no.


    3 years ago

    nice instructible, i've been looking forward to making this myself, but kept putting it off due to the lack of hotglue and a light source. I just recieved various 3W LEDs, including 4000k white leds (Because this color temperature has the best spectrum distribution). I was wondering whether you attempted to use a white LED as a light source. Indeed, the spectrum is not continuous (especially not in the green region), but this is why you take blank measurements anyway. The downside is that it will probably be less sensitive in the green area of the spectrum.

    Also why didnt you use a servo motor? I think it might allow for a higher wavelength selectivity. Also using a DVD, compared to a CD would increase both wavelength resolution and spectral selectivity.

    As addition for your spectra, i think a blackberry extract would be nice to see. (anthocyanin absorbance peak around 540nm, depending on sample preparation (pH, temperature, solvent)).

    1 reply

    Reply 3 years ago

    Very interesting questions and points, thank you.

    For one you are absolutely right about the blank! And with white LEDs it won't be as intense in bluish purplish region (scientific words I know) but like your statement implied: having a blank will subtract out the intensity anyway so as long as it's not too weak of an intensity it should theoretically work fine. In fact you brought up a very good point because tungsten isn't perfect either. It's just that it's so intense throughout the visible that it's a good choice. This topic specifically is one of the things I learned by building this instrument.

    Moving on, I did use a servo, did you mean to say stepper? One improvement if you are still going to use a stepper is to have the spectrum closer to the slit that way each step results in a smaller overall movement and hence gives you more wavelengths.

    And yeah changing up the diffraction grating to a DVD might be an option. Also going even further, one may be able to change the magnetic 1's and 0's on the DVD in a way that's benificial to the grating.

    Anyway as for your LEDs I say go for it. You don't need to build anything at all to test out the optics. I recommend doing that first before building anything anyway. Then maybe if you're satisfied you will have the motivation.

    I'll see about trying blackberry extract soon. If I do I will mention you in the section!


    3 years ago

    Interesting. I think you'd write something about the source lamp which must have the highest CRI possible (100), not all tungsten lamps have the same CRI (color rendering index). Did you make the measures with only the lamp ? You should obtain a straight line, no ?

    Anyway, very interesting.

    2 replies

    Reply 3 years ago

    I did indeed do a measurement with just the lamp. It was not a straight line. To my knowledge, it's not supposed to be because the tungsten filament varies with intensity across its wavelengths (unless I'm misinterpreting your question). This isn't a problem though because having a blank will set a reference point for each sample. Then the blank will be subtracted from the sample so that the intensity of the filament at the different wavelengths doesn't make it's way into the measurement. You make a good point though, for example had I used a "white" LED the intensity at certain wavelengths might have been too low for a measurement.


    Reply 3 years ago


    ** black body radiation // Wien displacment law - in Wiki .

    ** as it gets "hoter" - overdeive the lamp - goes to Infa red as experience , but more to UV as well

    ** correct re "white" LED

    ** few years back started to make own - but other "projects" captured the time

    ** the glass lens will stop uv and IR - whilst sample "tube" made of from silicon dioxide that pases those frequencies

    ** you learnt more by eve attempting to build an instrument than simply class lessons and set experiements - your instructor probably did as well