I designed and built a spectrophotometer. I prioritized simplicity over accuracy; the project uses as few components as possible. An LED shines light through a paperboard slit. The light passes through the cuvette, then hits a diffraction grating. A camera captures the spectrum; the image is processed by a Pi Zero WH. A tkinter GUI was written to operate the device.
Some spectrophotometers are calibrated using lasers of known wavelength. But this would increase the component count, so I wanted another method. I used the following method:
(1) The user places a sample with a known spectrum in the device. (I used olive oil.)
(2) The GUI displays a graph of the measured spectrum. By comparing the meaured graph with the known graph, I determine what the x-axis should be.
The device isn't very precise. Nevertheless, the machine is capable of differentiating between extra virgin olive oil (which is sometimes illegally adulterated) and canola oil.
After making the changes discussed in the previous posts, I tested the precision by measuring the same oil (Extra Virgin Sample 1) 3 times. Here is the result:
I also re-tested the different oils. I'm surprised (and concerned?) by how little absorbance was detected in the canola and light samples. But in general I think the results are decent.
Lastly, here is an updated illustration of the spectrum-finding GUI. The previous version shows inadequately collimated light; the issue is visible in the middle of the spectrum. This version doesn't seem to have that issue.
I fixed the bug that caused the x-axis to be reversed.
I realized that the light wasn't fully coherent when it reached the diffraction grating. (The issue can be seen in the middle of the spectrum image; there is white where there should be green and blue.) To fix this, I made a thinner slit and moved the LED back.
I decreased the resistor from 1 k ohm to 330 ohm. As expected, the LED is now brighter.
The holder for the diffraction grating was slightly wobbly. I glued it to the base. The glue is still drying; I plan to perform new tests this weekend.
I changed the code so that it takes 3 images and averages them, instead of taking 1 image. This dramatically improves the precision of the device.
I found a major bug in the code: the x-axis was reversed! This escaped detection because there are peaks on both edges of the olive oil spectrum. But when I started averaging images (see above), it became apparent that the right-side peak was much bigger than the left-side peak. This is incorrect; it caused me to investigate and find the bug. I still haven't fixed the bug; I need to do this before taking more measurements. The spectrophotometer is currently NOT accurate (because of the bug); it should NOT be used right now. I hope to fix the issue soon.
I collected spectra from 3 brands of extra virgin olive oil. I also collected spectra from light olive oil and canola oil.
The right side of the spectrum shows a clear difference between the extra virgin samples and the other samples. I'm worried that the left side of the graph is inaccurate. I'm not convinced that canola oil should have that much absorbance at low wavelengths.
Despite the possible issue on the left edge, I consider the test to be mostly successful. The device shows a clear difference between extra virgin olive oil and other oils, demonstrating its usefulness for food inspection.