Public Lab Research note


Sketches for a self-contained portable spectrometer using a Raspberry Pi

by warren | May 09, 2012 20:18 09 May 20:18 | #1936 | #1936

Trying to think of how to get a portable spectrometer working. A Raspberry Pi (once they start shipping more regularly) will be $25-35, so we could conceivably put one in the VHS case and have it record a spectra every X seconds.

Thinking of how to view it live, I was wondering about plugging it over 1/8" audio into an Android device and using the phone screen to display the readings. But for now I'm mostly thinking about a device you could leave outside for a while.


14 Comments

Something mobile is definitely a great idea. Funnily enough i was just looking at the rPi site before checking in here! A mobile spectrometer solution is something that i have been thinking about for a while now.

One way to have an interface could be to use a wireless dongle and run a web server.

Of course the hard part of it all is getting your hands on a Ras Pi at the moment...

Reply to this comment...


Did you see this post from last week? Very exciting: http://publiclaboratory.org/notes/warren/6-12-2012/mobile-android-version-spectral-workbench

BTW, I haven't been able to get a hold of mmittler (http://publiclaboratory.org/notes/mmittler/3-10-2012/spectrometer-hardware-higher-resolution) which is too bad.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


I did see that post about the android version. Definitely exciting stuff. Using a Ras Pi is a lot more suited to my application though being a data logger. I have no idea how i am going to achieve it, but that is the aim :)

It is a shame about mmittler not sharing his work.

I think that developing the spectoral workbench for the ras pi will get it into a lot of hands though. I did start looking at the code for the spectoral workbench, but it is a bit beyond my abilities to understand at this stage. Still, there is a huge potential i think.

Reply to this comment...


I bet he is just busy. Anyhow, do you anticipate that your ras pi will be online? or just recording to an SD card? The raspberry pi should be able to run the processing app, but maybe we could just write a script for it so it would store all the data in a directory, then have a script to upload it all when you get the SD card back to a web connection.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


Given the fact that i have just heard of the raspberry pi i am not too sure. Ideally what i would like is something that can process the spectrum, determine chemical concentrations and then store the data.

I expect that it will be a fairly long road to achieve that. You have to aim high though :) I am still not entirely sure how to apply the data provided in some of the links you provided for element spectrum.

Reply to this comment...


Something interesting. If you want to try your hand at the Raspberry Pi with out the hardware there is an emulator/virtual image available.

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=41&t=2961

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


We really need to find good numerical data for those spectra -- i only found graphs and don't really want to extract data manually from them. I'd love to find a good open source database we can just run a batch import from, so we have some important contaminant spectra in the system.

Reply to this comment...


Actually i did make a short list here of spectral databases we could probably import if we got them to open source their data:

https://github.com/jywarren/spectral-workbench/issues/54

Reply to this comment...


Those were the ones i was referring too. You are correct though that it would be hard work extracting the data manually.

Not only that, but i have no idea how you would take a spectrum and then determine the concentration of a certain chemical...

Is there a way i can get in contact with you about some ideas and questions about a possible raspberry pi spectroscope?

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


I'd love to brainstorm and offer suggestions -- but I am much more likely to do so if it's on this website, since then it's all open source. In general I'm not good at one-to-one correspondence, 'cause compared to putting it up on the PLOTS site it's kind of a bottleneck to open collaboration. I hope you understand.

If you post some of your ideas I'll definitely participate in comments etc!

Reply to this comment...


I certainly understand what you mean and my question was more along the lines of whether the mailing list would be more suited... I dont really understand the whole mailing list thing and its purpose. A forum just seems a lot easier to me.

I suppose that initially my questions would be regarding how and what to run on the RP. Taking into consideration what you have developed already, using processing etc, and the future direction you envision the project taking, whether that be a local program or web based. I noticed that one of the open issues on GIT is a completely web-based spectrometry client. If you think that a local program is still necessary then i am wondering if the overheads of processing will be too much for the RP to handle and it may become necessary to write it in another language such as Python, which then could be compiled for other platforms i think... Python seems to be able to do everything required and is able to interface directly with the webcam from what i can see here: Python webcam interface. Although, I dont know the capabilities of processing, so you may have a very valid reason for using it.

So i think the RP is definitely capable of achieving what is needed. I think it could even run a web server on it as a nice interface.

Please note that i am not trying to change the direction of the project or even suggest i know what i am talking about. I only have limited programming experience and your efforts have far exceeded anything that i could have achieved. I am just trying to understand where everyone is working towards so i can contribute in a useful way.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


Re: mailing list vs. forum, I agree -- i think the website (which has improved a lot recently) is a great place to do collab. research. I think the mailing list is older and many less internet-y folks are not as comfortable posting content as emailing people. It's low-barrier-to-entry. But go for it on the site if you're up for it.

The in-browser webcam version is actually already working in beta -- it's not as good as the java/processing client YET but it should get there in the next couple weeks. But it works:

https://spectralworkbench.org/capture

I think the python idea is golden and we should do it. The only remaining need for a desktop client is offline use -- which the web client, though very cool and easy, doesn't address. A RP would be the ideal use case, and if you want to run it without a monitor, you know, that's perfect. The python program would be minimal -- none of the cruft of a user interface -- and doesn't really need to be cross-platform, although that wouldn't be that hard either.

Yeah -- imagine you log into this RP from a laptop, (having copied the python Spectral Workbench program onto the SD card) and you start it up from the commandline. Then it is recording every X seconds into a folder, or into a long file.

I could see 2 ways to get the data off:

  • turn off the RP, copy the file off the SD card, and upload it to the SW website, which imports all the data
  • or, you can somehow log onto the RP using a browser while on the same wifi network and you see a webpage offering data for download.

Something like that. The first way is prob. easier. Cool. Do you have any Python coding experience?

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


With the in browser version, i thought a huge advantage of html5 is the ability to use a website offline. For example, if it isnt already, gmail will be available offline and you can store it all in the browser. One other advantage of this is that if a way is found to analyse the spectrum automagically to look for specific compounds/elements etc having it done locally will save a huge amount of server load. I am thinking in terms of having people 'set and forget' an analyser looking at a river water quality for example. (It is entirely possible that these could operate in a GSM network area and send out its results with something like: GSM Module.

html5 Offline Storage

I wonder if this is a way to provide offline usage and not have to maintain 2 lots of code? I dont know if the RP would have enough memory to run it in this fashion though... I know that using that emulator i mentioned certainly makes you appreciate both the impressive capabilities and the short falling in terms of memory compared to a PC.

I think you are using ruby on rails for your server side development? I wonder if my time could be better spent learning that. I dont have a huge amount (read: any :P) of python experience, although i was doing a bit of reading on it last night and it seems fairly intuitive and easy to learn. I might keep looking at it as an option. After all, i dont think it would be too hard to make it work with the API you have developed already to send spectrum images to the server.

So much fun to be had if only we could get our hands on a RP!

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


Using a pi is a great idea ! but still we have to found a solution to power the pi , i suppos that a power bank is enough! also you could add a blck chamber and a led to take the snape shot more precise !

Reply to this comment...


Login to comment.