# Question: Can I upgrade a DIY spectrometer with a Raspberry Pi camera?

warren is asking a question about spectrometry:

warren asked on September 28, 2016 19:13
1,302 | 3 answers | shortlink

### What I want to do or know

I've seen some of the really great work by @cristoforetti and the #webvalley group -- which I was lucky enough to help a bit on -- to build a version of our spectrometry kits around the camera from a Raspberry Pi mini computer board.

I'd like to think about how this could be done in a standard Desktop Spectrometry Starter Kit, as an upgrade -- or with a foldable mini-spectrometry kit.

On a hardware basis, this'd hopefully be as simple as gluing the Raspberry Pi camera (\$40 with the Pi Zero version board on Adafruit) in place of the webcam that comes with the kit, shown above.

### Why?

Raspberry Pi cameras can have auto exposure/gain compensation shut off, and a specific shutter speed manually set. This could do a lot to improve #exposure-calibration, perhaps adding to work by @stoft on #gain-correction.

Has anyone tried that?

(photo via Adafruit)

### Software

Getting the software running could be harder -- the Raspberry Pi isn't like a USB webcam, and if you're using it with a monitor & mouse, I'm not sure the camera would show up like a USB camera in a browser.

Note: see possible solution with V4L2 library, below in comments!

While the spectral-workbench.js library is capable of uploading data to SpectralWorkbench.org, meaning you can run it on the commandline of a Raspberry Pi,

Aside from uploading it as a still image, what more easier, simpler ways are there to use a Raspberry Pi-based camera using the live web interface at https://spectralworkbench.org/capture ?

#### 4 Comments

stef over 1 year ago

The BIG advantage of the Raspberry Pi is the use of the Sony IMX298 sensor whose spectral bandwidth is known and is 16 megapixel sensor. Much like the bandwidth of the solux 35003 light source bandwidth. I am awaiting the arrival of a webcam which uses the Sony IMC179 sensor 8 megapixel camera. The current camera is capable of 8 megapixel resolution but only 640 are used.. The solution may be to upgrade SW to selectively switch camera resolution as needed. I look forward to your success with the rasp Pi. stef

warren over 1 year ago

That's a great thing to point out -- do you per chance have a link to the spectral bandwidth of the sensors? Thanks!

Siphirobe over 1 year ago

I was wondering the same thing, just with the PiNoIR camera since I am more interested in remote sensing of vegetation.

warren over 1 year ago

I found that V4L2 driver apparently makes it possible to use the raspberry pi camera in Firefox with webrtc, the API Spectral Workbench uses: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=154437, which should be as easy as sudo apt-get install v4l-utils -- anyone able to try this?

Log in to comment

### 3 Answers

@warren

Here is a link http://www.khufkens.com/projects/ov5647-spectral-response/ and here is a zip file khufkens-pi-camera-response-curves-3342e29_-2-.zip Here are data sheets ProductBrief_IMX298_20160210.pdf and ProductBrief_IMX179_20140910.pdf

Unfortunately the curves end at 700nm. There is much more info in the first link. Regards stef

warren over 1 year ago

Oh great; @khufkens also shared that on this site! https://publiclab.org/notes/khufkens/11-02-2015/ov5647-raspberry-pi-camera-spectral-response-quantum-efficiency

Log in to comment

@warren

After sleeping it over, realized that due to the no IR filter of the raspberry the bandwidth response will be different from the published. BTW good luck finding one, seems everybody is out.

stef

Log in to comment

Just wanted also to link to @stoft's input on this question in this comment:

As to the RPi camera, it seems to have two "difficulties" which need solutions: 1) a "convenient" solution for interfacing the camera, controlling parameters and extracting image data from it (i.e. USB or other? ... I've just not seen a clean option) and 2) the lens. The mount and lens are very small and I've discovered (as noted in the above note) that a better lens (~8mm) is really necessary. All the added pixel data is useless if the lens is junk. There has been some hacks to the RPi for other mounts, but the RPi board is very small so the hacks are not easy or a clean drop-in -- from what I've found so far. I also have not found specs on the chip sensitivity and dynamic range -- which is necessary for comparing cameras. If the sensitivity is low, then the background noise can also "seem better" -- but that is not a measure of image "quality" -- it is sensitivity and dynamic range that count. Also, it would be good to compare cost of RPi + uC vs USB module types. The added pixel resolution of the monochrome I used did not appear to provide "clearly better" results than the more moderate cost ELP. No, that is not definitive numbers, but it just indicates additional details worth observing so as to compare specs that are of importance to the resulting spectra. So, I'm not rejecting the RPi, it just does not yet appear to be a drop-in option.

Log in to comment

Sign up or Login to post an answer to this question.