Does this project spark your interest?

Become a member to follow this project and don't miss any updates

DIY 3D Printable RaspberryPi Raman Spectrometer

An open source 3D Printable Raman Spectrometer using a RaspberryPi and easy to find off the shelf components..

21 100 79
Enjoy this project?
Share on twitter   Share on Facebook

This project was created on 05/30/2014 and last updated 2 days ago.

A 3D Printable Raman Spectrometer that uses a raspberryPi, a couple of arduino compatible ARM boards, a really bright laser and some parts you can grab from eBay, adafruit, sparkFun, Mouser, or wherever...!

1. Make it 3D Printable.
2. Make it modular and easy to upgrade.
3. Make it as easy to build as possible.
4. Make it easy to customize and open to improvement.
5. Use only commonly available off the shelf components whenever possible.
6. Have a remote interface that will allow it to be controlled and viewed from anywhere.
7. Compare the spectra to the online internet spectral databases.
8. Provide the capability to log data to remote databases, share with friends and colleagues..
9. Not be just another open source spectrometer..
10. Make it easy to use and intuitive.
11. Make it attractive with an elegant design..
12. Make it useful and just cool to have!

DIY Raman Spectrometer

Based on a Raspberry Pi and 3D Printable

Be sure to check out the bio that did on me!!


Imagine the keyboard in front of you... It is made of several's probably plastic, some metal, some silicon, and so on... Now imagine a glass of water, beer or your favorite soft drink.. So now let's ask what's in that probably know there's a bit of water, and a lot of other components.. What if you look at that beer, and want to find out what chemical compounds are in it.. So take a sample of it, and put it into a 'cuvette' which is a fancy tiny test tube of sorts.. Then insert that into our Raman Spectrometer.. Then run an analysis on it and bam! You can see that your beer has ethanol, carbon dioxide, water, etc.. 

Ethanol Spectra

There have even been examples of how you can distinguish different brands of beer using a Raman Spectrometer! You can do the same thing for other samples, like gasoline, your blood, tears, or even your cat's hair...


Raman Scattering

Basically, it works by shining a really bright laser through some optics to focus down to a sample...That laser light then hits the sample, and depending on the molecules it hits, and what they're doing...the light can be shifted up or down in color.. Some of that light, and some of the laser light is reflected back into the optics and goes back and is reflected through a couple of filters that removes the laser light completely..leaving only the shifted light from the sample.. That light is bounced off of a 'diffraction grating' which is sorta like a prism.. The light is separated and projected onto a camera(ccd) which takes an 'image' of the spectra. Then the computer analyzes that and compares it to a couple of online databases then comes back and tells you what's in your beer!

Lasers + Beer =


Process Overview

Start off by putting a sample in the cuvette.. Insert the cuvette into the DIY 3D Printable Raman Spectrometer, run the analysis.....the data is retrieved from the internet spectral databases, a match is found...that match is displayed on the users remote terminal...  You can store that data in an external database, share it online, or do what you please with it.. 


Optics Overview

1. The laser emits a 532nm (green) beam of light.

2. The 532nm Pass Filter only allows the 532nm (green) light to pass, and filters out anything else.

3. The Cube Beam Splitter passes half of the light on to the Objective Lens, and the other half into the Beam Dump.

4. The Objective Lens focuses the light down to a tiny point in the sample.

5. The light in the sample interacts with the molecules, and depending on vibrations, bond angles, etc. the light is shifted from 532nm (green) to other colors/frequencies.

6. Some of the shifted light and a lot of the original laser light is reflected back into the Objective Lens and is collimated back to the Cube Beam Splitter.

7. The Cube Beam Splitter reflects half of the light to the Filter Assembly and half back into the laser.

8. The Filter Assembly contains two Edge Filters which block the 532nm (green) laser light and allow the other colors to pass. Since this is a low cost system, two lenses are used instead of one Notch Filter...and so two separate exposures are taken and the images are stacked.

9. The remaining light is collimated by the Bi-Convex Collimating Lens to the Vertical Aperture (slit).

10. The Vertical Aperture (slit) controls the amount of light that enters the spectrometer section, and is a determining factor in spectral resolution.

11. The light from the slit is reflected off the Collimating Mirror on its way to the Diffraction Grating.

12. The Diffraction Grating acts like a Prism and divides the light into separate colors. Since the light originated as 532nm (green), and the shift is typically fairly minor, this light may be close to the original color...but also may be red (lower frequency) or even blue (higher frequency).

13. The light reflected from the Diffraction Grating is reflected by the Imaging or Focusing Mirror onto the Detector Array..

14. The spectra derived from the above process is reflected by the Imaging Mirror onto the CCD Array where it is captured by the raspberryPi for processing.. One image is taken with the first Edge Filter, then another exposure with the next Edge Filter and then some software to stack the images is used together along with some signal processing and possibly multiple exposures to gain as much brightness as possible so the computer can correctly analyze the spectra...

Originally I started out with a different configuration for mounting the optics. Since then, I decided to go with a much better solution where the optics are enclosed in a contiguous structure that eliminates stray beams and keeps ambient light out. It is also easier to set up, and should stay aligned longer in addtion to being more shock resistant and will reduce resonance.. The system is comprised of a number of individual modules, most of which are based around the optics listed above.

I have decided to go with the Crossed Czerny-Turner Configuration for the spectrometer portion.. It seems to be the best fit so far..

Crossed Czerny-Turner


Hardware Overview

A view from the outside... The whole thing fits in a Prodigy mini ITX case by BitFenix..

The electronics are centered around a raspberryPi. There are three microcontrollers tied to the raspi through rs-232.. The controlBoard, the interfaceBoard and the imagingBoard.. The controlBoard is also tied to the power control board... and at this time, the imagingBoard and the interfaceBoard may be living on the same PCB..

All three boards are based on the ST Microelectronics Nucleo F401RE STM32F401RE MCU and fit into what used to be hard drive trays that slide into the case..using a 3D printed adapter..

The Nucleo F401RE is just one of many platforms supported by mBed..  The boards shown below are prototypes, I'll be publishing the Eagle files for the new boards when I get the bugs worked out with these..

I am using the mBed online IDE to program them.. Say what you will, it works great.. gitHub to firmware..



Schematic for controlBoard can be found here.

  • Power Relay for Laser
  • TTL Control for Laser
  • Monitor Temperature for Laser using DS18B20 sensor
  • Control L298 HBridge for Heating/Cooling of peltiers on CCD Array and Cuvette
  • PID Monitor and control Cuvette temperature using DS18B20 and L298 HBridge
  • Monitor current draw from peltiers on CCD Array and Cuvette using ACS712 current sensor
  • Control Beam Shutter using a standard 9gram hobby servo
  • Detect Laser Good (verify beam is reaching destination) using a TEMT6000 ambient light sensor
  • Open and close Cuvette Tray using stepper motors driven by ULN2003, with optical end stops
  • Rotate Filter Wheel Assembly to change from 522nmSP to 550nmLP filters using ULN2003
  • Detect Filter Wheel Assembly position using rotary encoder
  • Monitor Cuvette Holder for presence of cuvette in tray using a optical proximity sensor



  • Accepts power from main power supply and distributed it to other boards
  • Contains the L298 HBridge for the imaging and cuvette peltiers



  • Arduino Pro Mini (for Adafruit RGB LED Ring which animates depending on activity)
  • ILI9341 2.2" TFT LCD Color Display
  • Capacitive Touch Panel with 12 'Buttons' using MPR121 touch controller
  • Displays system status and mini control interface
  • Accepts user input to open/close cuvette tray, etc..
  • LED Ring provides feedback regarding status, etc..


  • Controls Toshiba or Sony Linear CCD Array 
  • Monitors UV index with a 
  • *Controls diffraction grating angle
  • Transmits CCD data to raspberryPi for processing
  • Will probably be housed on the interfaceBoard...stay tuned.

Please read more......the description for the process has been updated!

Read more »


See all components

Project logs
  • Doing more than one thing at a time.....

    2 days ago • 0 comments

    So..  I've been meaning to give an update that shows a little history and some of my failures and what I did to get past them so far...  I'm still working on that.. :)  

    I'm doing this update to show a bit to round the edges on what I have been the past few days..

    As the previous couple posts show, I've been working on getting serial communications going.. I think I'm pretty satisfied with what I have..  It pretty much worked from the start, and there doesn't seem to be any packet loss....It could use some better handshaking and error correction, but that will come in time..

    So, currently.. I just got everything running from the mini-itx power supply.. the power supply plugs into a mini-itx connector on the power controlBoard and it passes the 5v to the controlBoard, interfaceBoard, and the raspberryPi, etc..  I'll put some pictures up as possible.. 

    In the meantime, here's a couple pictures of the laser emitter and power supply.. with the emitter seated into it's nice little case/mount...

    A view with the bottom half of the case removed....

    And a rear view showing the cooling fan...

    Here is a couple pictures of the mirror mount that bolts to the face of the laser emitter...

    Bottom half with mirror in place and simulated beam path...

    The whole unit.. The printing supports have not been removed in this picture... but it doesn't look a whole lot different after they are removed.

    Here is a photo of some of the optics... The important parts...the 522nm Short Pass filter and the 550nm Long Pass filter..  I'll post a photo of the actual filters soon.. I didn't have the gloves, etc. ready to remove them safely..  The other on the left is the surface mirror..which is in the image above...These all came from eBay.

    The transmission graph for the 522nm Short Pass Filter..

    The transmission graph for the 550nm Long Pass Filter..

    And a quick photo of all of the boards in the case hooked up..  

    So far....I have all of the boards (raspi, controlBoard, powerControlBoard, and interfaceBoard) running from the mini-ITX power supply... the raspi is running some test python code that cycles through a loop and sends commands to the controlBoard to move the cuvette tray back and forth, select the filter both with the stepper motors... It then cycles the cuvette and laser peltiers using the HBridge.. First it cools one side of the cuvette peltier, then heats it... and then it cools the ccd peltier...then repeats the whole thing.. Works great!  

    I'm quite happy that the HBridge controlled peltiers worked out so well.. It proves to me that I will be able to maintain the temperature of the cuvette using a PID controller and PWM and the DS18B20 sensors.. All the code is up on gitHub!

  • Update on printed parts..

    3 days ago • 1 comment

    I'm still in the design process for some of the printed parts... but here is what I have printed so far...

    • 1. Laser Emitter Mount
    • 2. Mirror Mount
    • 3. Laser Shutter Assembly
    • 4. Beam Splitter Assembly
    • 5. Beam Dump
    • 6. Objective Lens Mount

    I'm still designing the filter wheel assembly right now..  and then I will proceed to the rest...and the actual spectrometer... In the mean time, here's some terrible photos... It's apparently very difficult to photograph black plastic..  I'll try some better lighting as soon as I can..

    The Mirror Mount

    Mirror Mount opened up showing the inside...

    Laser Emitter Mount opened up showing the inside...

    Everything together that I have printed right now..  A similar angle to the rendered shot....

  • More serial fun..

    7 days ago • 0 comments

    So.. I have a pretty good working example going..  As it stands, I have the raspi commanding the controlBoard to check the laser temp, then check the cuvette temp, open the cuvette tray, close the cuvette tray and cycle through moving the filter wheel one rotation forward and then back...looping over and over just as a test...

    Some quick pictures...

    The controlBoard code for the command interpretation goes like this....(I couldn't fit this well using text)

    The functional python (raspi) side is as follows....

    and the command table looks like this...

    Basically, the raspi builds a command like the following req_laser_temp command...

               req_laser_temp = (chr(0xF0)+chr(0xF2)+chr(0XC0)+chr(0xC5)+chr(0xF2)+chr(0xF3))

    Which is:

    [0xF0] [0xF2] [0xC0] [0xC5] [0xF2] [0xF3] 

    or translated:

    [packet_start] [packet_flag] [cmd_laser] [req_laser_temp] [packet_flag] [packet_end]

    The controlBoard receives the command through the series of select satements a parses it starts by receiving the packet_start, which moves to the next switch case for sets the flag and starts a loop...and then moves to the next switch receives the cmd_laser and moves to the next switch case and receives does the temp check and sends the data...then continues in the receives the packet_flag, and moves to the next switch case and receives the packet_end which drops the flag and out of the loop...  waiting for another command..

    I haven't added acknowledgments, or much else really.. but this is working pretty solid for the moment..

    More tomorrow for sure..! (and of course... all of the code is available on gitHub right now...!)

View all 27 project logs

Build instructions
  • 1

    Preliminary instructions are as follows:

    Acquire the hardware listed in the parts list.

  • 2

    Print the 3D Printable parts.

  • 3

    Either etch, buy, or have made the PCBs you choose to go with.

See all instructions


Zeke_D wrote 9 days ago null point

Found a university example that may be of use for reference.
Keep up the great work. :)

Are you sure? [yes] / [no]

fl@C@ wrote 9 days ago null point

That looks very useful.. Particularly the CCD driving stuff.. I'll read this over tonight..!
Thank you, much appreciated..!

Are you sure? [yes] / [no]

Matouš wrote a month ago null point

Wow. I love this. I would love even more to build this or help to make it better in any way! I have actually attempted to construct a much simpler version of this with an LPC1114FN28 and some Toshiba CCD chip, but it ended up occupying one breadboard and not working very well - I could see some reasonable output with an oscilloscope, but the ARM chip is probably a bit too slow for driving the CCD, reading from it and sending the data over serial to PC. Always only one of those three worked at one time :) Anyway I did not have any of these fancy mechanics and optics, just the bare CCD, so this is a great step for me. Thanks for this a lot, I will study on how to build upon your work after exams :)

Are you sure? [yes] / [no]

fl@C@ wrote a month ago null point

Thank you! I'm always open to input and suggestions..! Sounds like you have some practical experience with the CCDs.. I'm still looking into options in that dept., but I hope to dive into it very soon.. I've been eyeing the sony ILX511 and the Toshiba TCD1304AP recently.. I'm glad that any part of what I'm doing can help... that's my main goal with this! I really want to narrow it down to the cheapest and easiest way to build and source everything. =)

Are you sure? [yes] / [no]

Marvin wrote a month ago null point

The Edmund grating listed is the UV optimised version. The VIS version is the same price. Is that intentional and down to a different use geometry?

Are you sure? [yes] / [no]

fl@C@ wrote a month ago null point

Oops.. Thanks for pointing that out.. It wasn't intentional..and related to my trying to do too many things at once.. :)
It should be the 1800 Grooves/mm, VIS Holographic Grating, 12.5mm x 25mm Stock #43-221

Thanks for pointing that out!! I'll fix that right now..

Are you sure? [yes] / [no]

sammy wrote a month ago 1 point

the actual photos in the project log really shows your progress. Impressive build!

Are you sure? [yes] / [no]

nmz787 wrote 2 months ago null point

Have you actually tested the device yet, got spectra and compared them to a reference spectrum (like how Ben Krasnow does in his video on DIY Raman)? The LP filter seems pretty far from the laser line, and I've heard the coherence is hit-or-miss on cheap diode lasers. I'd love to hear your experience! Your bio says you're using a raspiCam, I found the digital noise on my raspiCam to be quite high, so high I've discarded it as a usable imager for science. Did I get a crap camera? It was really bad in low-light for me!

Are you sure? [yes] / [no]

fl@C@ wrote 2 months ago null point

I've tested the optics and a bit of crude code I wrote.. Yes, there's about a 28nm gap which isn't optimal..but without spending more money that's the best I could do when I purchased also kinda depends on what deals you can find on eBay at the time.. I might end up replacing mine, but for now these should do.. There was actually a pretty in-depth conversation a couple days ago in the bio hackaday did.... Several imaging options, etc. were covered... it might be worth a glance.. :) I'm not convinced I'm still heading in the raspiCam direction, and if I will probably include a peltier cooler...

Are you sure? [yes] / [no]

nmz787 wrote 2 months ago null point

Reposting this here from my post on your bio page "​The simplest 'spectrophotometer mount' I know of is a concave aberration-corrected flat-field grating. It combines the czerny-turner design's mirrors with the grating, and has some optical engineering done to change the shape so the spectrum is fairly linear on a flat sensor like a CCD or CMOS."

Also, cooling the sensor will only reduce dark noise, not shot noise (including readout noise or other digital/amplifier noise).

Are you sure? [yes] / [no]

fl@C@ wrote 2 months ago null point

I am currently using a Horiba Aberation Corrected Monochromator Grating Type 532 00 110 ... I think I got it for around $49 on eBay..and there was more up last time I looked..
There might be better options, but part of the point of this project is to make it as adaptable to what people can find used on eBay so they don't have to spend so much money on new optics..

Here's a grating list that includes mine..

Spectral Range (nm): 190-800
Dispersion (nm/mm): 8.0
Grooves Density (l/mm): 1200.00
Deviation D (deg): 61.60
A: 100.00
B: 94.00
Blank DIm: 32.32
F: 3.00
Blaze: 250.00
Order: 1.00
Reference: 532 00 110

Are you sure? [yes] / [no]

nmz787 wrote 2 months ago -1 point

A monochromator grating won't result in a linear spectrum being imaged onto the sensor array, so comparing to a reference spectrum might be made difficult, but hopefully you'll be able to visually make some correlations! Check this app note out:

Also section 6 and 7 here (repost from Richardson Gratings):

Are you sure? [yes] / [no]

fl@C@ wrote a month ago null point

There seem to be several examples of how to correct for the non-linear spectrum (mirrors, etc) which shouldn't be a problem.. I'm also investigating linear CCDs for imaging and the possibility of a couple other options that will become more relevant when I am at that stage of development..

I'm curious about your design and why you chose such an expensive grating for an opensource project? Does the propeller chip offer any advantage over the Cortex M3? I found this ( ), which seems to be an old kickstarter campaign...have you made significant progress since then, have you imaged any spectra with this device?

Are you sure? [yes] / [no]

nmz787 wrote a month ago null point

I chose the grating because the simplification of the optical system seemed well worth it, it is a grating that is recommended for analytical/Raman use which is one of my intended uses for the device. The Parallax Propeller is an 8-core processor, so it is really good at doing things in parallel while still talking to each other. The instruction set is smaller than a Cortex M3, for that kind of processor I'd recommend starting with an LPC Link V2 which contains a triple-core Cortex M4 and two M0s, for ~$20... with an 80 MSPS ADC on-board too!

Are you sure? [yes] / [no]

Jrsphoto wrote 2 months ago 1 point

Great project! Was looking for your email but couldn't find it. I have some links about image stacking in python for the Pi that you might be interested in. It should get you pointed in the right direction. Some of these use this python camera lib:

However, would use this one, its much more capable:
Docs are here:

Stacking examples in Python:

Hope it helps,


Are you sure? [yes] / [no]

fl@C@ wrote a month ago null point

Thank you! And thanks a ton for those links! Those will most certainly come in handy!

Are you sure? [yes] / [no]

Mike Szczys wrote 2 months ago 1 point

Wow, that last build log is mamoth, nice!

Thanks for entering this in The Hackaday Prize. As you continue to document the project don't forget to take into account the Basic Judging Criteria on this page:

In general though, fantastic work on sharing all the info. I love it!

Are you sure? [yes] / [no]

fl@C@ wrote 2 months ago null point

Thanks Mike!! This is a pretty big project, lots of parts! I'm trying to make this as open as I can! All the files are up on gitHub!

I'll be sure to do that... I've been working on some ways to demonstrate the 'connectedness'.. It will be ultimately controlled by a remote interface on a PC, and the data can be transferred to other devices to incorporate in whatever experiments you're running... I had actually planned on developing a protocol so this device can talk to others I've created, allowing them to communicate and make adjustments automatically based on the output from the spectrometer and a couple other devices/variables...

I'm also really working hard to make this as easy to customize, and reproduce as possible.. I want to use the easiest to find/readily available components I can find for the cheapest prices..

Keep an eye out for the youtube video! And thanks to you all at hackaday for the chance to share my work! =)

Are you sure? [yes] / [no]

jaromir.sukuba wrote 2 months ago 1 point

Nice project.
I really appreciate finding and using relatively cheap and available components from ebay.

Are you sure? [yes] / [no]

fl@C@ wrote 2 months ago null point

I totally agree.. the savings can be amazing...if you can deal with the wait times.. ;)

Are you sure? [yes] / [no]

fl@C@ wrote 2 months ago null point

I'm working as fast as I can to get all the information up here as soon as possible!!

Are you sure? [yes] / [no]