Question: Dark images, can't get spectrometer to work

Tomas0413 is asking a question about spectrometer
Follow this topic

by Tomas0413 | June 16, 2018 12:06 | #16512

Hi, I get very dark images while using the spectrometer, so it seems not functioning correctly.

I also upgraded DVD grating with the upgrade from Public Lab ($10) it made no difference.

I pointed the spectrometer to the CFL bulb, and this is how it looks:

Also, it pretty much same when I point it to the sky.

The slit is the default one, I also ordered a set of slits, but the 0.4mm seems to be the same as the one in use.

Any help is very welcome.

image description


Hi! Sorry you're having trouble. My first thought is what direction are the grating lines going? They should be horizontal, or for the DVD, the edge of the disc should be at the top or bottom.

My second thought is maybe the grating is too far from the camera?

Also, is it possible you've not yet selected a good cross section? Try taking a picture through the webcam with a webcam app, or clicking the settings button while capturing?

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

Reply to this comment...

I would thing the first thing to check is whether or not the camera is working. Try removing the grating support or even pull the base out of the box and point the camera at a reasonably well lit scene. Open a web cam app on your PC and see if you get an image from the camera. If you have two cameras plugged in - the spectrometer and a web cam. Unplug the spectrometer and check you get an image from your web cam. Then unplug the web cam and plug the spectrometer camera in and see if you can see an image with that. Although this is a bit tricky on a laptop with a built in web cam. It may be a device selection problem - Spectral Workbench not selecting the camera or the right camera. On my system SB running via Firefox wont see the camera if I have a web cam plugged in as well. I also find camera sensitivity can be a problem. I use a camera app - GUCView - to adjust camera gain, WB etc before running SB. The camera settings I choose will persist if I close the camera app and immediately open SB.

Reply to this comment...

Darn - just went to edit a long answer and the PL web site deleted my save. Check the camera in the spectrometer works just as a web cam. If you have two cameras plugged in - spectrometer camera and a web camera - unplug the web cam, SW doesn't seem to cope well with two cameras. Try using a camera app such as GUCView to adjust camera gain, WB, etc. Setting will persist if you close GUCView and immediately click Capture on SW.

Reply to this comment...

Warren and Pushpaw, thanks a lot for the suggestions, I'm still looking at multiple things you suggested.

This is what I can confirm right now: 1. The camera itself works fine via, but only when I have the lid of the spectrometer lifted. 2. I removed the grating and the slit and just when I close the lid of the spectrometer the image becomes 100% dark.


I'll check your other suggestions and see if I can change camera settings.

Reply to this comment...

I should also add that the spectrometer connected to the MacBook, so checking how to control the USB webcam settings (hopefully for free, as some people suggest to buy this app

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

Reply to this comment...

Also worth noting that when I press on "Settings" here, nothing happens:


Huh, this looks almost perfect. Can you upload a picture of it with a light in the frame? I don't see any rainbow effects. Can you also send a pic of your DVD slice and its orientation over the camera? I worry it's not angled correctly and you're not generating a spectrum. You ought to see a bunch of rainbows here from these various lights!

Sorry it took a while to read through all the responses here but i'm glad you're getting help from @pushpaw too!

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

Reply to this comment...

Also tried both Safari and Firefox (while having Chrome closed). In both cases, there was a request for the permission to use the USB webcam, but nothing is displayed on the screen at all.



Reply to this comment...

OK well if I remember rightly Settings as you show above doesn't change the camera settings. It allows you to select your sample slice through the spectrum, if necessary to reverse the image and other stuff to do with the SW web interface. The SW pages can sometimes be a bit slow to respond making it hard to follow what is supposed to happen. Once the spectrometer is fully assembled there is often very little light coming through that slit. The dynamic range of the web cam is not that big so it can be essential that exposure and gain are controllable. Also things like white balance and or colour temperature will have an effect on your results. For calibration start with a CFL lamp really close to the slit and wobble the spectrometer back and forth to see if you get any kind of image. Usually with the lamp close you will get an overexposed image and need to either preset the gain and exposure or move the lamp away. If you still can't get an image either camera is faulty, is getting pre-set to low values of gain and exposure or the geometry of the parts inside your spectrometer is way, way off.

I also found this which, I'm reading at the moment:

Most webcams have auto exposure and color "correction" so that in dim light, you can still see. This will unfortunately change the exposure between readings, so for quantitative work, it must be disabled. On Linux, you can use the "uvcdynctl" utility as outlined here.

On a Mac, you can download this utility:

Reply to this comment...

Hmmm, I wonder if I need to install any special drivers for the camera for the Mac OS...?

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

Reply to this comment...

I don't know the Mac OS well but I'd guess there is a thing somewhere to manage devices and that should show your cameras. If you see two cameras then you have both a web cam and the spectrometer web cam connected and there will be an option to select between them. On my system SW and Firefox were not happy with having two cameras and tended to default to the wrong camera. So I unplugged my web cam.

I'm playing with this right now:

Might do the trick, I'll post the update

OK, I'll resume tomorrow, but feels like I'm on the right track. Thanks a lot for the help so far!

Hi, what operating system do you use? There's some guidance on webcam selection here:

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

Thanks, Warren it MacOs and I'm looking at changing camera setting. I hope something like this might help:

Reply to this comment...

For what it is worth, I just dug out and hooked up my prototype of the Public Lab Spectrometer 3 and, without fiddling around, got exactly the same result you have - black screen. I don't remember what slit size I have in there, but with any of the relatively small slits and given the degree of collimation along the length of the spectrometer there is a lot of attenuation. You really have to get the thing lined up with the light source and use a bright light source to get an image (as well as adjust the camera settings). It took a high intensity LED torch right up against the slit to get an instant and obvious image.You might try using the widest slit, I think that is a 0.4mm, or just cut a wide slit in a piece of card until you get the thing working and get used to how to set it up.

In fact, if you have your photo film slit mounted on the slide in piece of card. Just slide the slit out of the way altogether. This was you are pretty much guaranteed to get some sort of spectrum. Then progress to small and smaller slits.

Pupshaw, thanks I tried that, it made no difference. I'll try to get the camera setting changed. Didn't have much time in the last few days, but this is what I'm looking at:

Reply to this comment...

Tried building CamHolderApp from source, but had to download QTKit later, found that QuickTime has been removed from Xcode, etc.

Finally found a binary app:

Downloaded it, starts fine. Will try later tonight to connect to the camera and see if I can change the settings. I don't have the camera with me now.

This is the screenshot of CamHolderApp:


Unbelievable!, Linux has several free webcam utils and most web cams come with utils for Windows. I was struggling to come to terms with the idea that Mac OS has nothing bundled and that web cam manufacturers don't ship anything for Mac OS with their cameras, but it appears it's true. I guess this is part of the Apple 'It just works (except when it doesn't)' philosophy. A lot of the web cam utils that are available for Mac OS seem to be geared towards video conferencing and drawing silly facial features on selfies, which you don't really want. CamHolderApp seems of that ilk, it's designed for displaying what's happening on a smartphone screen and has things like Auto Focus that you probably don't want. What's needed for the spectrometer is a more nuts and bolts util that lets you set gain, exposure, white balance, colour temperature and so on. Then you need to work out which settings are best to set up the camera for best results in Spectral Workbench. Fortunately the Linux utility I use works with both my home brewed Logitech based spectrometer and with the camera in the PL Spec. 3. The tricky thing is that different cameras support a different range of controls and you need software that supports the camera you are using. GUCView supports both Logitech camera, which has more tweakable controls than the camera in the Spectrometer 3, and the Spec 3 camera. I did know what that camera was but I have forgotten.

CamHolderApp didn't detect the camera. So these are my next steps: 1. Connect the camera to Raspberry Pi Zero and access via VNC Connect: 2. Explore the idea of using Raspberry Pi Zero with its camera inside the original public lab enclosure (potentially with some 3D printed part).

Reply to this comment...

Also tried to build this app😀

The app starts but doesn't detect any UVC devices connected.

Reply to this comment...

Quick update:

Followed this:

And this:

And got capturing images on Raspberry Pi Zero W with Chromium browser.

Next steps: 1. Ordered a micro USB to USB cable, so I can try attaching the original camera to Raspberry Pi 2. Ordered a micro USB cable with 90 degrees up connector so I can fit the Raspberry Pi in the original Public Lab spectrometer box.

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

Oh wow!! I want to know more about this especially: capturing images on Raspberry Pi Zero W with Chromium browser.

Umm... It's quite a while since I fired up my Raspberry Pi but as far as I recall it has a couple of activity LEDs plus two status LEDs on the network connector. You really don't want a load of LED's flashing inside the spectrometer housing. I think you will have to mount it to one outer side of the spectrometer.

Hmm! Interesting point. I didn't think about the flashing LEDs! But thinking about this, it should be possible to put some black tape on the LED. I'll try it. Talking about Chromium+VNC there's nothing special about it. It's just starting VNC server and then instaling an launching Chromium browser. The main issue is speed. It takes type to start the browser and it's not comfortable to work with. I'll try if I can access via Raspberry Pi via HomeKit/Wifi from my Macbook. It should be possible.

My experience is that blocking all the light from a LED indicator is a lot harder than you might think. Other than disconnecting the LED's almost nothing will guarantee no light escapes. You could try smearing a blob of plasticine or blutack over them, but you still tend to get diffused leakage (from the PCB mounted LEDs) through the PCB itself.

OK! Maybe it's possible to just disable LED via software:

I can confirm that this tuned activity LED on Pi Zero off:

#echo none | sudo tee /sys/class/leds/led0/trigger none

echo 1 | sudo tee /sys/class/leds/led0/brightness


I can't edit the previous comment, I get an error when I try. This is what I wanted to post:

echo none | sudo tee /sys/class/leds/led0/trigger none

echo 1 | sudo tee /sys/class/leds/led0/brightness 1

Reply to this comment...

Quick update😀 1. I got the USB cable for the Raspberry Pi Zero delivered, however it doesn't fit into the original Public Lab enclosure. 2. I now installed Ubuntu VM via VirtualBox and posting this message from Linux. I'll try attaching USB camera to my Macbook and make it visible to Ubuntu.

On Ubuntu 18 via VirtualBox camera is visible to the OS and on you get a request for permission to use the camera. However the state of the camera remains "Requesting camera access... ".

I then tried "guvcview" and I get this error: V4L2_CORE: (get_v4l2_frame) video stream must be started first

I spent some time trying to resolve this issue, but I couldn't. I'll try older version of Ubuntu sometime later.

Reply to this comment...

Update: got the camera to work on Ubuntu!. The issue was fixed by installing VirtualBox extension pack and choosing USB 3.0 (instead of USB 1.0 )

Reply to this comment...

I'm now able to control UVC Camera settings, however, the images are still dark when I close the list. I was hoping to be able to set Auto Focus to on or off, but I can't find such setting.

These are the settings I can change:


uvcdynctrl -d video0 -c Listing available controls for device video0: Brightness Contrast Saturation Hue White Balance Temperature, Auto Gamma Power Line Frequency White Balance Temperature Sharpness Backlight Compensation

Reply to this comment...

uvcdynctrl -d video0 -c Listing available controls for device video0: Brightness Contrast Saturation Hue White Balance Temperature, Auto Gamma Power Line Frequency White Balance Temperature Sharpness Backlight Compensation

This is great to see. Good work!

Thanks! Warren maybe you can post the settings that you use so that I can try them tomorrow?

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

I actually usually use default webcam settings! So going back to the original question, I believe there may be an issue with the angle or the orientation of the DVD... sorry, it's getting quite difficult to follow all the threads on this page --

In this comment:

You had a perfect image, so I don't believe there is a problem with the camera itself.

But I don't see any spectra even in that image, where we should. Can you upload a new picture similar to this one but clearly showing the DVD orientation?


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

Thanks for the response, I’ll upload tve image tomorrow. But aa far as I remember even if I leave only the camera inside the box the moment lid closed - it’s complete darkness. I saw somewhere on PublicLab that cameras were out of stock and then new ones arrived. Could it be that the model is slightly different? Could it be that the camera you use has AutoFocus off by default and the one I have AutoFocus on without an option to turn it off?

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

For example threre’s a similar camera on AliExpress and the description says that it’s AutoFocus and that this can’t be changed : Look what I found on AliExpress

Great, i look forward to seeing the photos. Please also upload one of the front slit of your box!

I don't think autofocus would cause complete darkness! I'm eager to see how the grating is aligned and hope we'll solve this that way. Fingers X!

And this example says FixedFocus:

Look what I found on AliExpress

Your Guvcview control panel looks much like mine running on a real Ubuntu PC (If I understand you correctly you are running it in a virtual machine). Camera settings persist after I close Guvcview. Not sure why you mention auto-focus, you don't want it and I'm pretty sure the camera that ships with the spectrometer doesn't have it. Spectral workbench and /or the browser can be very picky about accessing the camera. When you run Guvcview do you see a spectral image in the viewing window? If not something is wrong with your slit or your diffraction grating.

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

Pushpaw, thanks for the reply.

Not sure why you mention auto-focus, you don't want it, and I'm pretty sure the camera that ships with the spectrometer doesn't have it.

I mentioned Auto-Focus, just guessing what if the camera model I received is not correct and what with I received a model with Auto-Focus. I took a picture of the camera and it says "NB23 S2", and the model I found on AliExpress ( says it's fixed focus. So maybe this isn't a problem. I also removed the grating completely. So when the lid is lifted, I can get a good picture. When I close the lid, the image turns completely dark.

Warren, for now, I just completely removed the grating. And actually, I no longer use a slice of DVD, I bought a set of gratings (an upgrade). When I had grating installed, I noticed that part of the image is covered, so I need to check why. But still after having the entire grating removed, still have 100% dark images when the lid is closed.

OK - that's OK, the camera should be looking at the dark inside surface of the lid. The grating or DVD should bend/refract the light downward into the lens -- this is why i'm concerned about the orientation of the grating.

For a DVD, it's easy to see when the curved outer edge of the disc is at the top of the box. For film gratings, this is harder to determine, but you can try rotating it 90° and trying it both ways -- it has a directionality, basically.

I would try with the DVD first just because it's easier to know when it's properly aligned. Then upon confirming nothing else is wrong, and it's working, switching over to the grating again.

Can you upload a picture with the DVD in place? Thanks!

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

Thanks for prompt replies. I'm travelling now without access to the spectrometer, I'll share new photos on Mon/Tue next week.

Reply to this comment...



As far as I can see that camera placement looks as it should. Going off on something of a tangent, do you happen to have a laser pointer. If you point the beam of a laser pointer through the spectrometer slit with the beam passing parallel to the base of the spectrometer when it strikes the diffraction grating it should bend down and pass into the camera lens. Probably best to temporarily stick a bit of white card over the camera lens to avoid danage to the sensor. This is why it is important to have the grating oriented correctly - the line across the grating need to be parallel to the base of the spectrometer so the diffracted beam bends down. If the lines of the grating are at right angles to the base the beam will bend to one side (well both sides actually). Does anyone have a handy drawing of the spectrometer geometry showing the light path? That might help.

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

The grating orientation might be the thing. I somehow didn't think about it before. I do have a laser pointer, and when I tried a few weeks ago, I was able to get something when pointed to the slit. It's just that "something" didn't look right. I think I have to check what about doing with that grating... I feel the "aha moment" is getting closer :D

Just tried it and it is important to note that what you will see is 3 dots once the laser beam has passed through the diffraction grating. One is where the beam passes straight through and then there are two diffracted beams one below the main beam and one above. And you can see the direction of the track / lines on a DVD by just reflecting some daylight off it. You will see a reflected spectrum at right angles to the lines. I'd assume the same was true for any diffraction grating. But note that the diffraction angle is dependant on the LPI of the grating. If you are using a piece of commercial grating that is not as fine as a DVD the light may not be bending far enough to hit the camera.

Quick update:

The grating orientation might be the thing.

I tried 4 * 2 = 8 combinations for the grating, and it didn't make any difference - in all cases, the camera gets entirely dark once I close the lid. I'll have to step read all the comments once again and think about what to do next...

I have also a spectrometer version for the mobile phone, so I'll what are the results with it and maybe it will help to figure out what is wrong.

Reply to this comment...

Log in to comment