Public Lab Research note


This is an attempt to replicate an activity.

Lego spectrometer - Publiclab design

by lach_myers |

Read more: publiclab.org/n/16660


Sorry about the ridiculous thumbnail - I assumed it would be reduced!

I used the instructions provided for the build phase.I raided the (grown-up) kids Lego(tm) trove for the pieces and now have a tasteful red and black Lego(tm) spectrometer.
image description

  • I have a set of Publiclab acetate collimation slits, and I'm currently using a 0.12mm slit which is the second narrowest in the set.
  • I had a mini/phone paper spectrometer, so I cannibalised that for a Grating mount and liner. The liner is a necessary part, as I noticed a good deal of flare when testing (with an LED torch).

Hardware: Raspberry pi zero wifi version and the v2 (8M pixel) picamera.
Software: Raspbian Stretch - updated regularly - using the Core-electronics and Publiclab install notes, and RPi Cam Control v6.4.21, via a direct HTML interface. I have changed the default settings very little - just a 90degree rotation and turning on titles. I will try out the cedarlodge GUI when I organise a usb mouse/keyboard combo.

Below is an image for the CFL calibration test. I'm reasonably pleased at this result.

However, the image looks a little out of focus, and I would like to improve this - would a longer body (more Lego(TM)) help?

image descriptionFollowed



spectrometer spectrometry fluorescence raspberry-pi lego raspberry-pi-spectrometer lego-spectrometer

response:15360 replication:15360


8 Comments

This is the best. Thanks for posting, and great documentation!!! 🎉 😀 👍


I think you can use a very fine pair of tweezers to slightly rotate the Pi Camera lens for a focus change. Do post if that works for you! But yes, a longer lego case may also work. I would like to know if focus changes are needed, though, as we can modify the kit or instructions. Thanks!


Hello! Nice work on the raspberry pi version of the spectrometer!

A question, for @Warren , does PublicLabs provide the NoIR version of the Camera? I'm currently working on this spectrometer for my college's Civil Engineering department. We originally started with the webcam, but found its limited range unhelpful for our desired applications (testing for metals in drinking water). As such, we've switched to a NoIR Raspberry Pi Camera which seems to be working alright (assuming I can replicate what was done up above. I didn't know there was a control program!). I was just wondering whether or not PublicLabs provides that specific camera in their kit.

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


We don't by default but probably should list that option as we do stock them. Can you email kits@publiclab.org to place an order?

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


I bought one independently, though I do recommend that you offer that option. The stark contrast between the webcam's spectrum range and the NoIR Raspicam's is striking.


OP again. Mine is the standard (IR filtered) V2 camera, as I wasn't sure how the software would handle the non visible end. I've started investigating the focus issue and find that its quite a topic (thanks @warren) https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200 and my version (2.1) is affected most - the lens has to be loosened and then it can be adjusted. Solutions are;

  • tweezers or needlenose pliers are one way but this risks lens scratches,
  • a hack using a credit card, a 5mm drill and some filing/cutting https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971545
  • a hack using a 2 x 1 Lego(TM) block that I couldn't get much info on https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=425#p1259809
  • a key - 3D printed https://www.thingiverse.com/thing:1574661 or available from Adafruit https://www.adafruit.com/product/3518. A similar one is apparently supplied by RS Components with the v2 picams
  • The last (Adafruit) is available from Core Electronics here in AU, so I've ordered one and will report. I'm also doing some rough tests to establish current focus at about 80mm which is the approximate distance from the camera to the collimation slit on the Lego Spectrometer.

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


    OP Focus tests completed, with and without grating, and both show out-of-focus problems at all distances from about 80mm to over a meter - which is a little disappointing, but hopefully solved by the key I've ordered.


    That's too bad - we can possibly start shipping keys with these if this affects everyone. A meter is pretty bad! We couldn't lengthen the case that much...


    You must be logged in to comment.