DIY Low Cost Spectrometer

34,451

387

50

Introduction: DIY Low Cost Spectrometer

About: We are two young inventors, Kousheek Chakraborty and Satya Schiavina. We like using digital fabrication, electronics and various other fields of knowledge to create projects that focus on simplicity, efficienc…

Being a final-year undergraduate student majoring in physics, I believe that labs and practical experiments are just as important as the theory when it comes to subjects like physics. Lab sessions and experiments provide tangible results which often help clarify the concepts much more effectively than a lecture. However, due to the global pandemic, we have not had a lab session for over a year now.

Most experiments, especially in the final year of an undergraduate physics course require complex, intricate, and highly expensive instruments and equipment. However, in our course, the spectroscope experiments caught my eye and I decided to build a low-cost version using materials that are available in every household.

I am also interested in the field of computer science so I decided to make a digital version of a spectrometer using a webcam, and create a program to analyze the results.

Follow on to create your own DIY Low-Cost Spectrometer and do drop a favorite and follow this page if you enjoyed the project and decide to build your own version. I would love to see your own versions so do post your creations using the "I made it" section.

Step 1: Overview of the Theory of Spectrophotometry

The concept of spectroscopy is generally elaborated in undergraduate-level physics courses, however, here is a brief explanation about the theory behind spectroscopy and the spectrometer.

A spectrometer is a clever instrument used to measure the properties of light. This allows scientists to use this instrument for a vast number of experiments such as determining the materials found in objects used in day-to-day life or determining the elements found on distant stars and planets.

The basic concept of a spectrometer is that an "unknown" beam of light is flashed onto an optical element that splits the beam of light based on the wavelengths present in the "unknown" beam of light. Each wavelength is deviated a different amount, therefore by measuring the deviation, one can determine the wavelengths present in the "unknown" beam of light, which could potentially provide more information about the source of the beam of light, even if it originated millions of kilometers away.

In earlier times, scientists used prisms to split the beam of light into its components, and a pivoting eyepiece to measure the angular deviation of each wavelength component. However, more recently, the prism is replaced by a diffraction grating that serves the same purpose as the prism, and the eyepiece is replaced by an electronic photoreceptor array that is connected to a computer.

Step 2: Materials Needed

Here is a list of all the components and parts required to make your very own Low-Cost Spectrometer. All parts should be commonly available and easy to find and you may already have them lying around in your home.

Materials:

  • Cardboard
  • Black chart paper
  • Old DVD disk
  • Razorblades
  • Webcam
  • Glue
  • Tape

The total cost of the project excluding the webcam is less than 5$.

Step 3: Building the Enclosure Pieces

The enclosure could have been made using any kind of box but I decided to create one from scratch to make it the perfect size for the webcam that I was using. Begin by taking the measurements of the webcam:

  1. Height
  2. Width
  3. Height of lens

Build a box according to the following measurements:

  • Length - 20 to 25 cms
  • Width - 2 cm larger than the width of the webcam
  • Height - 1 cm taller than the height of the webcam

Trace the 6 faces of the box according to the dimensions onto a piece of cardboard and use a knife to cut the pieces out. On the rear face make a slot through which you can pass the webcam's cable and on the front face make a 2cm x 1cm slot in the middle at the height of the camera lens.

Stick all the faces onto a piece of black chart paper using glue and cut the paper along the boundaries of the cardboard pieces.

Note: It may be useful to mark the faces using a pencil to avoid any confusion.

Step 4: Assembling the Enclosure

Grab the bottom face and the two side faces and place them side by side. Use tape to join the three pieces together. Next, attach the front and rear faces using more tape by making sure that the orientations of the faces are maintained.

The top face is attached along a single edge so that we can open the enclosure using the top face like a hinged lid in case we need to make any adjustments later. To prevent any light from entering through the top, cut some more pieces of cardboard to make a slight overlap.

Peek into the enclosure through one of the slots and make sure that no light gets into the box. An extra layer of electrical tape or any kind of non-transparent tape can be used to cover up small gaps.

Step 5: Making the Entrance Slit

To make the entrance slit, tape one of the razorblades vertically to cover up a portion of the gap on the front face. Tape the second razor blade next to the first one by using a single sheet of paper to create a thin gap between the two blades. Tape the second blade and use electrical tape to cover any gaps to prevent any light from getting into the enclosure.

Step 6: Making the Diffraction Grating

This step is the most crucial part of the project. The diffraction grating is responsible for splitting the beam of light according to the wavelength. One option would be to buy a diffraction grating directly. These are usually available online for about 4 to 5$. The other option is to use an old DVD disk for the diffraction grating. Both provide similar results.

Begin by cutting into the disk using a pair of scissors. As you cut deeper into the disk, you will notice that the disk consists of two layers that will begin to split apart. Split the two layers completely and discard the half that consists of the silver coating.

Cut a quarter piece out of the second half and square the edges to form a small rectangle that is a little bigger than the width of the lens.

Next, use some glue to stick this piece onto the lens. Make sure to use temporary glue so that you can remove the diffraction grating in case you want to reuse the webcam.

Note: One crucial step for your spectrometer to work is that the concentric grooves along the disk are lined up such that they are vertical, that is, they need to be parallel to the slit. If they are not parallel to the slit, the diffraction will not take place.

Step 7: Mounting the Camera

Once the diffraction grating is stuck to the webcam, pass the cable through the enclosure using the rear slot and place the webcam towards the rear of the enclosure at a 30-degree angle with respect to the front face, and aligned with the slit in the front. Before sticking the webcam in place, connect the webcam to a computer and open the camera app. Point the spectrometer towards a source of light and adjust the position of the webcam till the diffraction spectrum is positioned in the center of the image.

At this point, you can stick the webcam to the bottom face using double-sided tape.

Step 8: Testing

To test if your spectrometer works correctly, point it at a source of light and adjust the height of the light source and spectrometer till both are aligned. You can use a pile of books or something else to adjust the vertical alignment, I decided to use some old 3D printer filament rolls.

Connect the webcam to a computer and open a camera app. The image should consist of a neat diffraction spectrum.

You can further decorate and label the spectrometer using printouts.

Step 9: Using the Analyzer Software

Simply having a picture of the spectrum may not provide much information, so I designed a program in Python to plot the intensity of light. This will provide the relative distance between "peaks" which can be further used to determine the wavelengths present in the source of light.

To run the program you will need to install Python on your computer along with a few additional open-source libraries. Python can be downloaded using the following link https://www.python.org/.

The additional libraries can be downloaded and installed using pip through the terminal. The libraries along with the terminal commands are provided below:

  1. Opencv - pip install opencv-contrib-python
  2. Numpy - pip instal numpy
  3. Matplotlib - pip install matplotlib

Once all the libraries are installed, you can clone the spectrum analyzer program from the following GitHub repo: https://github.com/kousheekc/DIY-Spectrometer-Analyser

Run the program and you should see the webcam feed. Point the webcam to a source of light and press the "r" button on your keyboard to capture the region of interest of the feed. Click and drag your mouse over the spectrum and press enter. Once the region of interest is selected, press the "s" button to capture a frame and analyze the intensity using a graph visualization. You can use the "q" button to quit the program.

Step 10: Final Results

Once you have tested the spectrometer and the software program, you can begin your experiments. You can point your spectrometer at various sources of light such as CFL bulbs, neon lights, incandescent bulbs, or even smart color-changing LED bulbs. You can also step outside and point the spectrometer into a clear portion of the sky and explore the results.

To measure the wavelengths of a certain light source you can begin with a source of light with a known wavelength such as a laser and determine a relation between the position of the peaks and the wavelength.

There are various other fun experiments that you can try such as detecting and measuring sodium in table salt and detecting chlorophyll in olive oil. With this low-cost spectrometer, you can perform various simple and interesting experiments right from your house.

Hope you enjoyed this Instructable and it has inspired you to build your own DIY Low-Cost Spectrometer. This was originally targeted towards undergrad physics students who are unable to conduct practical experiments and labs due to the pandemic, though the process is simple for anyone to follow without the need for a formal physics background. I would love to see your very own versions of the spectrometer so do post them and the results using the "I made it" section. Apart from that, feedback, questions, comment, concerns can be addressed in the comment section below.

Happy Making!

Explore Science Challenge

Grand Prize in the
Explore Science Challenge

3 People Made This Project!

Recommendations

  • Stone Concrete Cement Contest

    Stone Concrete Cement Contest
  • Remote Control Contest

    Remote Control Contest
  • Build a Tool Contest

    Build a Tool Contest

50 Comments

0
gleuea
gleuea

Question 22 days ago on Step 9

Hello, I did build the spectrometer but am unsure how to get all the python libraries installed correctly. I did get python installed and tried to get the three libraries on correctly but when I try to run the program, I get a CV2 error. Not sure what all of that means or if I have those three libraries installed correctly? I unzipped the opencv-contrib-python-4.6.0.66, numpy-1.22.4, and the matplotlib-3.5.2, and now have those three folders. So, when I open the python launcher and try to run the spectra python program, I get the following info (see image.). Thanks for helping! Alan

Screen Shot 2022-06-08 at 4.46.01 PM.png
0
billdebs60
billdebs60

4 months ago

Great project, simple and powerful! Two questions:
1) If I remove the IR filter on the sensor, will your software work with the extra IR data?
2) I have a 8 megapixel camera, any reason the current software would not run? & Any value in so much data?
Thank you

0
davidmardy
davidmardy

Question 6 months ago on Step 8

You are still not clear on how the spectral image is on the outside of the enclosed box. Have you cut a window in the cardboard box --- I don't think this would work. see section 8

0
ptamte
ptamte

Answer 6 months ago

That is only a printout that was attached to the side for decoration. It isn’t a spectral image being displayed by the spectrometer. The spectral image is only visible on the laptop screen.

0
jazekerxx
jazekerxx

6 months ago

amazing project! thanks for this. you should start a youtube channel, showing home made lab equipment and what you can do with it. i'm very interested in that because i have no education in these topics and you explain it very well.

0
gkmarsh
gkmarsh

Reply 6 months ago

Guys, This is called Chemistry - which many professors thereof, can be found on YouTube. Pick the one you like.

0
crazybioteacher
crazybioteacher

6 months ago

Did you remove the IR filter? and second to this question will the software recognize ir? I am going to build a few of these with my class as it’s a great way to introduce spectrophotometry and I was just interested to see if you think IR is also possible?

0
lufer2000
lufer2000

8 months ago

Hello.
Before my question, thank you for this instructable. It's fantastic.
I made and it's working fine but I've just one doubt. How do you get the rgb lines? I only get a blue one.

0
GuyS38
GuyS38

Tip 11 months ago on Step 10

Brilliantly simple. The work of an hour to put together and the included software works perfectly. I needed to compare the relative wavelength of blue LEDs. By using a red laser along with each blue LED, I was able to see the relative distance of the blue peak from the red peak. (See my Ï Made It)

0
Technovation
Technovation

Reply 11 months ago

Thank you and glad to hear your positive results!

0
sublishop
sublishop

12 months ago

Wow impresive!!!

0
Technovation
Technovation

Reply 11 months ago

Thanks!

0
edward.cronus
edward.cronus

12 months ago

Excellent, I've been looking for a digital spectrometer. I will definitely build this! thank you so much for all the information

0
Technovation
Technovation

Reply 11 months ago

Thank you!

0
lacovara
lacovara

1 year ago on Step 10

Very nice, and very nice results.

0
Technovation
Technovation

Reply 1 year ago

Thank you!

0
nzpntn
nzpntn

1 year ago

Very nice work!

0
discostu956
discostu956

Question 1 year ago

Nice project. Looks useful for some projects I do.

On the graphs you put up, there are multiple lines at the same wavelength, say the first image with a peak in the blue, yellow and green lines at around 140nm, with different intensity of each. Just wondering what the different lines are representing and why they are all showing at the same wavelength, rather than just the overall intensity at each wavelength (one line)?

Thanks for taking the time to post this project up

0
Technovation
Technovation

Answer 1 year ago

Thank you! The yellow line represents the intensity, the blue, red, and green lines represent the blue, red, and green light intensities respectively. It's simply an added feature that may be handy to debug problems.