The SpectraCam Project: Revision 6.

Welcome to the SpectraCam project page hosted by Walla Walla University. This project was developed and is maintained by Dr. Tom Ekkens. If you have comments or suggestions please send email to This page was last updated on August 19, 2018.

Revision 5 of the SpectraCam uses simple tooling and PVC parts to make the spectrometer.  Now that 3d printers are common and cheap, the build process was refined to put some of the work on the 3d printer.  The resulting Revision 6 is faster to assemble and uses fewer parts.

Bill of Materials

DescriptionPart NumberCostSource
1½ ABS cap012871529771$2.56Home Depot
11” of 1½" pvc conduit722669$4.77Home Depot
ABS "Camera holder"   
M2 x 4mm  socket cap screw532512 SHB$1.26Amazon
USB 2MP webcamJDEPC-OV05$30.00Public Labs
Flat Black paint020066197674$3.63Home Depot
Plastic Diffraction Grating 1000 lines/mm$5.00Ebay
Black Card Stock759598993705$8.26Walmart

Set up the Camera

  1. Remove the lens from the camera.
  2. Turn the lens housing over and remove the reddish glass.
  3. Spray with compressed air to clean and reassemble the lens to the camera.
  4. Plug in the usb camera to a computer running Windows 10 - 64 bit.  
  5. Copy “SpectraCam.exe” and “opencv_world330.dll” to the computer.  The file “opencv_world330.dll” is part of the OpenCV 3.30 package.  The file “SpectraCam.exe” can be obtained by emailing the author of this page at the address above.
  6. Start SpectraCam and press “Start”.  Once the image is live, right click on the image and check “Full Image”.  If you do not see a picture, change the USB Port from 0 to 1.
  7. Once you have a good image, set the focus to about 12 inches.  Work slowly, the image is averaged over a few seconds.
  8. Prepare the diffraction grating.
    1. Cut a 5 mm x 5 mm piece of diffraction grating to fit over the camera.
    2. Orient the diffraction grating so that light is bent along the long axis of the camera board.
    3. Put a tiny bit of black paint on the camera housing and glue the diffraction grating down to the top of the camera.  Do not get so much paint on that the camera hole is covered.

Prepare the ABS and PVC

  1. Drill a hole in the center of the ABS cap.  
    1. Use a 0.0217” drill bit and try to put the hole as close to vertical at the exact center as possible.  Be aware that the drill bit is very fragile.  
    2. Use a 0.0276” drill bit by hand to make the hole a bit bigger.
    3. The completed part is shown in the picture below with the location of the hole indicated by the red arrow.
  2. Use a saw to cut a piece of 1½ inch PVC conduit to a length of 11”.  (This lets one sheet of paper sit in the tube without bumping.)  Smooth the ends of the cut if desired.
  3. 3D print the camera housing.
    1. Start with the file “Camera Holder R11.STL” and print it from ABS.
    2. Once the print is done, tap the two holes with a 2 mm tap. 


  1. Roll a piece of black 8.5” x 11” cardstock up and slide it into the tube.
  2. Slide the PVC cap unto the tube and lightly push it down.
  3. Attach the cable to the camera and bend it around the left side of the camera.
  4. Slide the camera into the camera holder so that it fits in the slot and the plug is held down by the finger.
  5. Attach the camera to the holder using a single M2 metric screw.
  6. Push the cable into the cable slot as shown in the picture at right.
  7. Push the camera housing onto the tube.

Alignment Check

  1. Start the software and press “Start”.  Once the image is live, right click on the image and check “Full Image”.
  2. Aim the tube a fluorescent light.  You should see a picture similar to the one at the right.
  3. If the colored dots are not close to a horizontal line, you will need to rotate the camera focus knob slightly to get them as close to horizontal as possible.
  4. Once the dots are horizontal, remove the camera from the housing and apply two dots of paint at the top and bottom edges of the diffraction grating to hold the diffraction grating down better.
  5. Apply a spot of hot glue to the lens/housing interface to keep it from moving.
  6. Once the glue and paint is dry, reassemble the system.


  1. Start the SpectraCam program and point the spectrometer at a fluorescent light.
  2. Click the “Start” button to begin capturing data and once again to end capturing data and hold the last data.  You also can use CTRL + Space Bar to toggle the camera.  You should see a picture similar to the one below.  If a warning message about the camera not being found appears, change the “Camera #” from 0 to 1.
  3. With the camera stopped, press the “Auto” button.  The two numbers in the “Blue” and “Red” boxes should change slightly.
  4. Check the quality of the calibration by selecting “Fluorescent Light” from the dropdown box titled “Fit”.  This will add colored bars indicating the expected peak location to the line scan. Many of your peaks should line up with the bars.  (This calibration data is adapted from ).
    1. The first order lines are shown in red and the second order lines are shown in green. 
    2. You can adjust the “Blue” or “Red” numbers slightly to try to make the peaks line up better.
    3. The camera doesn’t show all the lines since it only has a range of 380 nm to 900 nm.
  5. Once the camera is calibrated, these two numbers should be entered for each set of data.
    1. The calibration data scan be saved to the local computer by using the the “Save Calibration” entry from the menu accessed by left-clicking on the upper-left icon.
    2. Moving the camera to another computer will require the numbers to be entered by hand but will not require another spectra of the overhead lines to be taken.
  6. The “Brightness” dropdown box can be used for dim samples.
  7. Data Saving.
    1. The data can be saved using the “Save As” entry from the menu accessed by left-clicking on the upper-left icon.  This data can be loaded back into the SpectraCam software and modified.
    2. The data can also be exported as columns of numbers from that same menu.  Once it is in that format, it cannot be loaded back into SpectraCam.
    3. Also from that menu, the view on the screen can be saved to a PNG file.  The resulting file cannot be loaded back into the program.

Using the SpectraCam

Once the SpectraCam is completed, it is time to use it and measure things.  The most obvious sample is the fluorescent light that was used for calibration.  In the picture below, the red and green lines are the expected values for the first and second order lines.  Additional data is shown in the Revision 5 page.