This is a testing site only. See the live Public Lab site here »

Public Lab Research note

Raspberry Pi spectrometer GUI

by cedarlodge | March 07, 2018 16:12 07 Mar 16:12 | #15880 | #15880

cedarlodge was awarded the Basic Barnstar by warren for their work in this research note.


The interface now includes keyboard controls for capturing images.

Settings can be changed in the settings menu, but will return to default when the program exits.

Spectra can now be viewed by clicking on the spectrum image.

My own experiment with making a graphical interface for the Lego Spectrometer.

The program will capture the image, pull out the middle line of pixels and expand it into a spectrum for uploading to spectral workbench.

Alternately the middle line of pixels is preserved in a different folder for use with scripts such as spectral-workbench.js.

Right now the camera is set to a 30 second timer, but I am working on finding a way to capture keyboard events in python to trigger the image capture. Failing that I will instead install a tactile button, but I would rather avoid this as I would like this script to be as useful to as many people as possible.

I also have plans to include menu options such as changing the camera timer and exposure settings.

please note that the script uses a fair few libraries, but IDLE will tell you which ones to install.

If you have any issues or suggestions please let me know, either here on or the github repository.

I did this Help out by offering feedback!

People who did this (0)

None yet. Be the first to post one!


@warren awards a barnstar to cedarlodge for their awesome contribution!

Reply to this comment...

Thx for sharing this and I would like to run the code (as soon as I build the spectrometer). Two questions:
1)Are you using a Pi v1 visible camera? 2) How do you know where to draw the 'center' line since the spectrum shifts across the vertical.

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

Reply to this comment...

The camera I ended up using was the camera for pi zero with infra-red filter ( With the centre line, it's more that the line is there to allow the user to line up where the spectrum is on the screen, the line of pixels directly below the white line is what the script stores. With mine it's a case of nudging the spectrometer left or right until I'm happy and then hitting the spacebar to capture.

Let me know how running the code goes, especially any bugs.

Reply to this comment...

How's this going, @maggpi?

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

Reply to this comment...

I also recently found an old monitor i'm going to try this with :-)

Reply to this comment...

Sorry i forget, but is there a possibility of entering a token on the Pi and having the spectra upload to ?

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

Reply to this comment...

Not yet, It's my half term break in about two week so I can get back onto it around then.

Reply to this comment...

Hi, thanks for this - I'd like to ask for a couple of clarifications, if I may? 1) I presume this interface needs a monitor on the HDMI of the PiZeroW? 2) I'm new to Python/IDLE - does this need to be run via IDLE GUI or can I set this up to run this from a browser (like the RPi Cam Control)? Moz

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

Reply to this comment...

@lach_myers You are correct, the interface needs to be displayed through the HDMI lead. Currently the code is still in development so it does need to be run through the python3 IDLE. There's also a lot of library dependencies but IDLE will let you know what needs installing when you run the code.

Reply to this comment...

Login to comment.