Building a DIY Spectroscope [Video]

24 May 2024

In this post we’ll use a camera, an analogue pocket spectroscope and some software that I wrote to build a digital spectroscope. The spectroscope will be limited to roughly the visible range of light (~400nm to ~700nm). While it’s probably not as accurate as commercial devices we will calibrate it carefully to give decent results.


Sometime last year I saw a YouTube video by Les’ Lab in which Les used a laser to remove the color filter array of a Raspberry Pi camera. Then he put a pocket spectroscope in front of it and read out the data to get a rudimentary spectroscope.

I thought the idea was quite cool but the calibration wasn’t very involved. For the calibration of the horizontal axis (pixel to nanometer mapping) he used lasers, which I think is fine1, but from what I remember there was no calibration of the vertical axis, i.e. of the intensity of light. Diffraction gratings such as those used in diffraction spectroscopes don’t transmit the same amount of light at all wavelengths. So without calibration the intensity of light shown across the spectrogram is probably not accurate.

The major problem that I can see, however, is that I and probably most other people don’t have a laser at home with which we can remove the colour filter array of a cheap camera.

The other videos I’ve seen on the topic don’t remove the colour filter array but they read the data right off the JPEG. That may be fine if you’re only dealing with the relatively smooth spectrum of lamps. Once you point your spectroscope to measure the spectral lines of the sky, however, you’ll get much less accurate results (demosaicking …).

So when I had an idea of how we could achieve a reasonably accurate spectroscope without removing the colour filter array, I just had to try it.

You can find the code that I wrote for this project on github. The README.md file on github also includes more details on the optimization process.


Footnotes:

  1. Although from what I’ve seen lasers can quite easily damage your sensor so you have to be very careful if you use one. I wouldn’t even use laser pointers to calibrate the pixel to nanometer mapping … ↩︎

This post is tagged as:



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *