Sneak peek: 3D-printable mini spectrometer

I thought I’d take a moment to show a sneak peek of a something I’ve been working on for the Mark 5, an inexpensive 3D printable mini spectrometer. (The Mark 5 is going well, by the way — The first prototype is half-built, and I successfully communicated with it’s linux console over USB this weekend!)


This is a prototype Open Mini Spectrometer, a very small, inexpensive, and partially 3d-printable mini visible light spectrometer for embedded systems. Technically it has two components, the detector electronics, and the spectrograph.



The detector board contains:

  • a TSL1401CL linear CMOS detector w/128 channels
  • an AD7940 external analog to digital converter (14-bit @ 100kSPS)
  • a small power filter
  • a standard 0.1″ header to easily breadboard the spectrometer or connect it to a microcontroller (including an Arduino)
  • a 4 x 2mm-hole mounting pattern to attach the spectrograph
  • for the stand-alone pcb, 2 x 3mm mounting holes (one on either end)



The prototype spectrograph is an experiment in low-cost design, and is almost entirely 3D printed using ABS plastic on an inexpensive desktop 3D printer (such as a Makerbot, though I used an ORD Bot Hadron). I have much more experience designing electronics than I do designing optical systems, and so the spectrograph is designed to be swappable/upgradable as newer designs come to pass (and I expect it to go throught a few iterations). This first spectrograph design has a 3D printed slit, and uses an inexpensive 1000-line/mm diffraction grating of the kind you can find on diffraction grating slides for classroom experiments. I read a paper a while ago on using deconvolution to post-process the data from slit spectrometers and basically sharpen the point-spread function (or PSF) to effectively increase the resolution of the instrument. Inspired by this, I decided to leave out the relay optics between slit-to-grating and from grating-to-detector to see if I could use post-processing to effectively sharpen up the overly broad PSF and have an even simpler and less expensive instrument.

The spectrograph design:

  • contains a ~0.2mm printed slit
  • 400-700nm (approx) spectral range
  • Variable spectral resolution (~3.3nm @400nm, ~1.8nm @ 700nm), not accounting for the PSF
  • 1000 line-per-mm diffraction grating (cut into a 4mm wide strip, and inserted into the spectrograph flush with the slit aperture)
  • 3D printable on an inexpensive printer
  • Very small size — about 1cm wide x 2cm long x 3cm tall.

With a spectrometer you’re often battling for SNR, and have to worry about stray light. Although these pictures don’t show it, the spectrograph has to be spray painted with a flat matte black paint to get any kind of performance.

Example Data:

I connected the open mini spectrometer to an Arduino Uno, and wrote a quick sketch to acquire spectral data and send it serially to a Processing sketch. Let’s have a look at some data collected from the instrument from two light sources — the first a white LED, and the second a red laser diode. The following images include four subplots: (1) the raw detector data from the light source, (2) a baseline measurement to determine the ambient light, (3) the difference of 2 from 1, to arrive at just the light from the light source, and (4) the spectrum re-sampled from variable (1.8-3.3nm) to evenly spaced spectral bins:


White LED

Red Laser Diode (~650nm)

Currently it has all the performance you’d expect from a $20 spectrometer with no relay optics — the PSF is quite broad (the FWHM on the laser diode is about 20nm), and although the printed slit is fairly deep there’s still a fair bit of translation on the detector depending on the spatial location of the source. I haven’t had much luck using deconvolution to sharpen the spectra, but I don’t have a great deal of experience with deconvolution on noisy data.

All of that being said, it’s a great first prototype in a functioning state, and with plenty of potential for improvement!

In terms of cost, in small quantity the detector boards have about $20 of parts. If you’d like to use an external ADC, I’ve included a solder jumper to output the raw analog voltage on the CS pin, and this also reduces the cost in small quantities by about $10. The spectrograph can be made for the cost of printing, painting, plus the cost of the diffraction grating. I think the materials cost for me was probably less than $1.

Source Files:
The source files, including the Eagle files for the PCB, the Google Sketchup and STL files for the current spectrograph, as well as sample Arduino and Processing sketches (and example data, in CSV format), are available on Thingiverse. The code portions are released under GPL V3, and everything else under Creative Commons Attribution Share-a-like 3.0 Unported, both freely available without a warranty of any kind. If you’d like to order prototype PCBs from the same place I ordered them, the project is shared on, with each set of 3 bare boards available for about $5. These revision 1 boards change very little compared to the boards pictured above — a few vias have been moved to help make the design more light tight, and I’ve added in a solder jumper for those who would like to use an external ADC.

Contributor TODO List:
The open mini spectrometer is an open-source hardware project. Want to contribute? Here are a list of near-term todo items:

  • Find a source of tiny inexpensive relay optics (~4mm dia, short focal length) that are repeatedly and consistently available in both small and large quantities
  • Design a better way of inserting and securely mounting the diffraction grating
  • Modify the spectrograph to include relay optics
  • Try printing the spectrograph using different materials. How does the slit hold up? Are there materials or methods where the slit is printed better (e.g. SLS? Inkjet?). Are there matte black build materials that do not require the spectrograph to be painted prior to use?
  • Use the mini spectrometer to measure a variety of known spectral sources, and post the data
  • Modify the pi filter for better noise rejection. A good deal of noise still appears to come through the USB port/Arduino and into the spectrometer, requiring a greater number of averages for a clean signal. Battery power should also help with this.
  • Handy at signal processing? (and, specifically, deconvolution?) Feel free to grab some sample spectral data from thingiverse and see if you can improve the PSf and effective resolution with some postprocessing.

The Science Tricorder Mark 5 contains the same footprint for the spectrograph, so for compatibility I’d greatly prefer to keep the physical dimensions and the mating portion of the spectrograph the same (unless there’s a compelling reason for change, of course).

Thanks for reading!

19 thoughts on “Sneak peek: 3D-printable mini spectrometer

  1. First great design! I want to do something similar but using the Sony ILX511 CCD

    You say that you have a problem:
    “I haven’t had much luck using deconvolution to sharpen the spectra”

    I have an idea of what it might be…

    Ok, you did this:

    “Inspired by this, I decided to leave out the relay optics between slit-to-grating and from grating-to-detector”

    Do you take into account that removing the relay-optics between the grating and the detector will give lots of small spectra?

    For each order m in the basic grating equation, spectrometers usually supress zero-th order and all other orders except the one they use.

  2. Thanks! I’d love to see your ILX511-based spectrometer when you get it finished!

    I’ve tried to be a little clever to avoid some of the issues with removing the relay optics by having the grating sit flush against the slit, and by making the slit deep — it’s about 4mm in height, I think — so the while the light coming out isn’t technically collimated, you might be able to argue that it’s pretty close and avoids some of these issues. I’ve also experimented with putting the sheet of diffraction grating through a laser printer to print on a slit of different thicknesses, to take the slit-grating distance from near zero to actually zero.

    The 0th order should pass straight through to the printed beam dump that has a small angled baffle to help absorb the light and prevent it from scattering — this was necessary for good performance. I don’t think any of the nth order fringes are interacting with the detector — I’d at least expect to see them when measuring the impulse (the monochromatic laser source), and that’s a very clean measurement.

    I’m not sure whether the lack of success on the deconvolution front is due to my lack of experience on real, noisy data, or a limitation of the technique. I’ve heard the technique itself tends to perform very poorly on noisy data. After trying a gaussian PSF without luck I just took the measured PSF from the laser as the kernel and tried to back out an impulse (and less aggressive more gaussian shapes) without much luck, but I could simulate it just fine. Maybe it’s a bug in my code. When I get a chance, I’ll try to take another look! Or someone with more experience deconvolving things from real data can download the sample data from Thingiverse and give it a try themselves, of course.

  3. Yeah I would love to see that spectrometer to, Im good at starting projects…
    But now I’m confused ? Why would the light be collimated if you are close to the slit? I thought the slit worked like a pinhole camera at least across it (if it is not to narrow then diffraction comes in), and then you would need a concave mirror to make collimated light. And If you use a refractive grating I thought you needed a high angle of incidence to get refraction at longer wavelengths (to satisfy the grating eq.)…but not 90 degrees.

  4. I’ve got a bit of experience with spectrometers. It’s a little unclear what your optical design is. Where is the grating? It looks as if you’re using a transmission grating at the slit. What makes the slit? Is it electrical tape or the plastic? You have a curved slit entrance but a flat exit with no baffle. Why?

    Do you have any 2D images of the spectra? Are you really sure you’ve got only +1 order? What absorbs the 0-order? The PCB? There’s a white line and a spot of gold on the PCB where the 0-order is. I would recommend black felt, or a blackened mirror pointed into a baffles pocket opposite the sensor. Also use black plastic, as it will reflect less. There are a variety of factors that probably are broadening your LED blue peak and the diode line.

    Do you have some information on the sources? To you have access to a calibrated spectrometer, filters or gas lamp lines?

    • Hi there — I think most of these questions can be answered by reading the “spectrograph” section of the blog post, and the comment above — but let me know if anything is unclear, after that.

  5. ok so “inserted into the spectrograph flush with the slit aperture” means you have a transmision grating that was not clear…. Maybe the simplest spectrometer would be to have a narrow narrow slit and use the diffraction from the slit only and no grating….

  6. I am replying to myself here..because having only a thin slit as I said above will only work if linput ight is collimated. I think that is your problem (as you say yourself too) non collimated light would be like having multiple sources of light with different angles of incidence…to the grating thus you would have a lot of overlapping spectra..and this would look like noise. Try testing with a long thin (black) pipe before the slit…if that makes SNR better then.. collimation would be the problem..

  7. You have lost me, but it sounds like you’re interested in spectroscopy, but maybe don’t have a formal background in optics, and are a little confused about how a slit spectrometer functions and how the different design parameters influence the system’s behavior and output? If so, and you would like to learn more, Hecht’s “Optics” is a wonderful text with a broad coverage from introductory to advanced material.

    To complete the “modify the spectrograph to include relay optics” contribution, someone will likely need a solid foundation in optics, and (optionally) access to some optical design software like zemax. To complete the “Signal processing/deconvolving the PSF” contribution, someone will need a basic background in signal processing, the sample data (that’s available for download on Thingiverse), and a copy of a package like MATLAB or Octave. In terms of suggesting that the design has errors, I’m very happy to be convinced that the current spectrograph design has problems with stray light, extra diffraction orders overlapping, or any other issue or area for improvement — that’s the very nature (and one of the best aspects) of an open project. But in order to contribute to the project and successfully convince me you’ll have to provide compelling evidence, both in the form of a specific description of the issue, a well thought out argument, supporting data if possible, and (optionally, and ideally) a patch to the issue. As it is, the design performs almost exactly as I’d expect, and I’m not able to see any of the issues you’re discussing in the data.

  8. I have the Hecht book but it was 19 years ago I read it. So yes I am trying to understand and help because I want to build my own. Also I have worked with signal processing and Matlab since 1992 however not exclusively. Basically what I am saying is that non-collimated input light would be like having multiple sources of input light with different angles of incidence…now that would cause overlapping spectra and obviously be bad. What I ment with the that it would create light coming from mostly one direction. I mean why would placing the transmisson grating close to the slit give collimated input light??

  9. Reading my own posts again I realize I was not clear… the long pipe would filter away any light that is not travelling parallell to it, filtering away light that is not collimated to begin with.

    Thus the light coming from the pipe would be more collimated but at a loss of intensity. The idea was then to use this light as input light just to test if the signal to noise ratio improved. So nothing more than a test to learn more…but it might not be practical to do in reality.

  10. The CAPTCHA stuff on this pages is terrible annoying.
    I need need nearly 10 trial to get it done 🙁

    Is the TAOS Sensor a readymade product or did you make it yourself ?
    If readymade, may you share productinfo, please ?

    Any experience available her on Sony ILX 554B ?

  11. Hi Wally,
    The TSL1401CL sensor from Texas Advanced Optical Systems (TAOS) can be found at Digikey, they’re about $7 in single quantities.

    I’ve not used the Sony ILX series before, but most linear sensors are very similar and require only a few pins to operate — a line to clock the data out, and a pin to start/stop the sampling. Usually there are specific timing requirements to determine the integration time (the amount of time light is collected for — this should be short in cases where there’s lots of light, and long for cases where there’s little light). I chose the TSL1401 because it’s extremely small and operates from a single supply (3.3v). It’s noise characteristics are nowhere near a scientific-grade sensor like from Hamamatsu, but for a $7 chip, it makes a great educational embedded spectrometer.

    • You’ll likely want/need a much higher performance system for a Raman head, depending on what it is you’re trying to measure. Assuming you had a notch filter to remove the excitation frequency and narrowed the wavelength range, it might be possible (in principle) to integrate long enough to see some of the Raman signal.

  12. Hello
    I have the device as described above setup with the Arduino and Processing, but my graphs in Processing are blank (except for the odd bit of noise).

    Would it be possible to confirm the pins used for the Arduino. I currently have:
    [PCB -> Arduino]
    SI -> Digital Pin 2
    CCLK -> Digital Pin 3
    MISO -> Digital Pin 4
    SCLK -> Digital Pin 5
    CS -> Digital Pin 6
    VCC -> 5V
    GND -> GND

    • Hi Greg,

      Those pinouts look correct. Here are some debugging steps that may help:
      1) Is the integration time set too low?

      2) Double check that there is power where it should be — 5V on the input to the mini spectrometer board, as well as after the Pi filter, and on the input to the linear sensor and ADC.

      3) Does the graph show some signal when the spectroscope is not attached to the board (i.e. just the sensor, looking at light?). If yes, then it’s likely a mechanical/spectroscope issue — perhaps the aperture isn’t open, or the grating is misaligned.

      4) If no, does a signal of the spectrum show on a scope when examining the output of the linear sensor, and input of the ADC? If yes, the issue is something to do with the ADC, if no, the issue is likely something to do with the linear sensor.

      5) If it’s the linear sensor, double-check that it’s installed in the correct orientation. If it is, try to get some signal out of it when placing it in light — if you can’t, the sensor may be damaged.

      6) If it’s the ADC, double check that this part is in the correct orientation as well — it’s also easily (accidentally) reversed.

      Let me know how it goes!

Leave a Reply