Recently, I tried making a visible spectrometer using the Raspberry pi, the camera module and Mathematica. Details are posted
here, but here's a brief summary. The spectrometer is built out of legos and a few components found around my house (and since I'm a Chemistry professor, diffraction gratings and cuvettes are really found around my house).
The light source (in the upper right hand corner) is a white RGB LED. Immediate to the left is the sample compartment (which unfortunately is just a little too big for a standard sized cuvette). Next comes a transmission diffraction grating which is a common supply in general physics classes. I then use a 10x magnifying lens to condense the light onto a business card. At the bottom right in the picture is the camera module (connected by the white ribbon to my Raspberry Pi and mounted using a hodge-podge of Legos). The camera is pointed towards the business card.
Unlike
my first version of a spectrometer, this version doesn't require any additional GPIO interfacing or MathLink programming; everything can be done within a typical Mathematica notebook without additional packages. I acquire images using Import and then use ImageTake to grab just the region of interest. Here are some example images of the empty spectrometer and with three samples: water, green food coloring and red food coloring.
In order to get spectra out of these images, I do 3 things:
1. Convert the images into data with ImageData and then average each of the rows
2. Convert the y axis into absorbance.
3. Calibrate the x axis by assuming that the RGB LED emits red, green and blue light at the expected wavelengths.
The code for these steps is fairly straightforward, and demonstrates how easy it is to manipulate Images, process array data rapidly, and perform linear fitting statistics with just a few lines of code. For the samples above, I ended up with the following spectra:
The results are decent, given the quick and dirty calibration, the limitations of my source and the lack of any robust alignment of my "optical bench". With some modifications, I suspect I can improve the wavelength resolution, although I will probably be limited by the source, which doesn't have a continuous emission across the visible region of the electromagnetic spectrum. The system is easy enough to build at home, however, to serve as a spectroscopic tool for science fair experiments or other kitchen chemistry projects.