Here at Hackaday, we love it when someone picks up the ball from a previous project and runs with it. That’s what we’re all about, really — putting out cool projects that just might stimulate someone else to extend and enhance it, or even head off in an entirely new direction. That’s how the state of the art keeps moving.
This DIY spectrometer project is a fantastic example of that ethos. It comes to us from [Michael Prasthofer], who was inspired by [Les Wright]’s PySpectrometer, a simple device cobbled together from a pocket spectroscope and a PiCam. As we noted at the time, [Les] put a lot of the complexity of his instrument in the software, but that doesn’t mean there wasn’t room for improvement.
[Michael]’s goals were to make his spectrometer a little easier to build, and to improve the calibration process and overall accuracy. To help with the former, he went with software correction of the color filter array on his Fuji X-T2. This has the advantage of not requiring a high-power laser and precision micropositioner to ablate the CFA, and avoids potentially destroying an expensive camera. For the latter, [Michael] delved deep into the theory behind spectroscopy and camera optics to develop a process for correlating the intensity of light along the spectrum with the specific wavelength at that location. He also worked a little machine learning into the process, training a network to optimize the response functions.
The result is pretty accurate spectra with no lasers required for calibration. The video below goes into a lot of detail and ends up being a good introduction to some of the basics of spectroscopy, along with the not-so-basics.
That’s not a Spectrometer. It’s is a Spectroguesser.
I’ve seen better implementations using a CD, a box with a slit and a camera.
You can also use color filters in front of a camera/light sensor (side to side, or alternate them on a wheel) and then combine the light intensity values of the filtered light.
There are dedicated chips that measure spectrum, such as the AS7265x (6 bands, 3 variants, combine the 3 variants and you can get 18 bands).
Thank you.
I have experimented with CD based spectrometer to study Covid-19 coronaviruses in saliva.
Just coincidentally I suggested off my trusty publiclab spectral workbench, which is literally a webcam, a stripped dvd for diffraction grating and a slit, folded in some cardboard. It whows colleagues and kids every time.
More info please!
Haha, yes, I think you could call the calibration “guessing”. But it’s an educated guess based on the best data we can get without (expensive) professional devices. Incidentally, this “guessing” also happens when you use the jpeg of a regular camera (as you would when you use a CD and a box with a slit). There, one of the first steps of creating the jpeg – done by your camera – is to apply the white balance to the red, green and blue signals (this is done before the demosaicking process). This white balance is just a multiplicative factor on the red and blue signals (the green one is normally set to 1). These factors are determined by your camera based on a sensor and heuristics. So the output you get when reading a spectrum off a jpeg depends on the white balance that was used when creating the jpeg. A different white balance will result in a different spectrum (the details depend on how exactly you extract the spectrum from the jpeg). So how accurate your output is depends on how accurately your camera estimated the white balance. A good camera may do it well in most cases, a cheap webcam will probably not do it as well. In either case, the “guessing” of the white balance is done by the camera and you don’t know how accurate it is, so you don’t know how accurate the resulting spectrum is.
Also, unless you’re really familiar with the image creation process you wouldn’t even think that this issue exists. In the video this uncertainty about the calibration is explicit so you know that it’s there. Also, you get a qualitative (and in some way also a quantitative) idea of the magnitude of your uncertainty and you can improve the accuracy by using better lamps and a more careful calibration. So there is really no way around some inaccuracies unless you do a very careful calibration with very accurate components.
Regarding the use of colour filters in front of your camera. For that to work you’d have to:
– know the exact wavelengths that the filters let through (there’s always a range of wavelengths that can pass),
– know how much of the incoming light the filters let through at those wavelengths, and
– know the spectrum of your light source that shines through the colour filters.
Even if you know all of that you’re no better off than in the video because you’d have just as many uncertainties (and unless you manage to get a very narrow range of wavelengths at a time you won’t be able to do it at all). Moreover, you need a lot (an infeasible amount) of colour filters to get anything close to the wavelength resolution of the video.
Regarding the AS7265x, I’ve never used it myself so I have no first hand experience. But from what I can tell the chip measures the intensity of light at 18 wavelengths. I have not checked the wavelength resolution of the spectrogram in the video but there are way more than 18 data points.
You raise some good points. You definitely need a camera where you can turn off auto white balance and can get raw images.
My point is that this solution requires constant re-calibration ever time you use it. If you use an adapter for an expensive camera you will take it apart to use the camera for something else or to put it away. Then you need to re-calibrate.
Also this type of calibration isn’t perfectly reliable. Using LEDs or lasers with known wavelength or using filters of known wavelength is probably more reliable.
You are right the AS7265x has fewer bands. But they are calibrated. So if your use case is to find the color temperature of a light source it is perfectly capable. If you need to find holes in a spectral band to identify chemicals, then it is useless. So it depends on the usecase.
> without (expensive) professional devices
Calibration sources, like every other kind of hardware, can be hacked. Spectrum tubes run in the $50-$80 range, about what you can buy a low pressure sodium lamp for these days. Add a suitable power supply and you’ve got a physically-based calibration source. “Suitable” for a power supply here is going to require learning something about gas discharges, but that information is readily available, even if not currently very popular.
Hummm. Reads HaD headline. Seems more like a spectro-photometer (ie uses photons and light to do stuff). Clicks link and thank goodness it isn’t a YouTube video but headline by that guy only ever refers to it as a spectroscope.
I usually associate “spectrometer” with, like, mass spectrometer
“An optical spectrometer (spectrophotometer, spectrograph or spectroscope) …”
https://en.wikipedia.org/wiki/Optical_spectrometer
Outstanding work! Would love to see it perform some basic analytical chemistry.
Why are HaD comments so terrible? What is it about this site that brings out the most critical ungreatful cranky people? With almost every article people line up to crap all over other people’s efforts. Almost like it’s a sport to tear down other humans. What if people posted constructive tips instead? Wouldn’t that be nice? Life is too short to spend it making yourself miserable by trying to find the flaws in what other people do because somehow, someone’s hobby project doesn’t live up to your standards.
This. Thankyou.
Well said
Your comment is an example of what I call toxic positivity.
Toxic positivity is a serious problem. Toxic positive people cannot stand any type of negativity or even neutrality. Like a dictator demanding everyone claps.
Some people write constructive criticism using facts and logical arguments and even provide alternative solutions. But even that is too negative for the toxic positives.
The irony is that that the response of toxic positive people to non-positivity is itself often very negative.
In your example you call comments “terrible” and people “ungreatful[sic]” and “cranky”. I think you missed the point. Someone spend a lot of time to create a professional looking, yet purposely misleading, video and to top it off the article on HaD is misleading too. As a small hobby project it’s fine, but if you shout how great it is from the rooftops you should expect people to complain about their time being wasted by more clickbait stuff.
And most of the cranky responses are indeed cranky, not offering USEFUL criticism! They’re techbro sniping, trying to prove they’re the smartest kid in the room.
How about we get LESS of that?
You are being completely confused about when to call something toxic positivity, because the hackaday comment section is rife with senseless or useless negativity and nitpicking.
Calling that out is a realistic view of what’s happening here, and not toxic positivity.
To be fair, I think that Internet comments elsewhere are also terrible. But yeah, comments like these _do_ make me think that we might need a tighter fist on the moderation. I wish it weren’t so!
I’m leaving [C]’s original (non-constructive) comment because [mpr] comes in and addresses a number of the misconceptions about the simplicity of the device that [C] appears to have.
FWIW: It’s totally fine to be a little bit ignorant about something. I’m a little bit ignorant about a heck of a lot. But if you _are_ a little bit ignorant, it’s best to not be nasty.
Welcome back from vacation!
Thanks!
I’ll skip the out-and-out trolls who care more about being ugly to others than about being right or wrong, and skip this article and project to speak generally.
Often the remainder of harsher critics have a problem with something specific in the article or the original project and were just weren’t gentle about expressing it. While sometimes this subset don’t know as much as they think they do – and I’m sure I’m no different – at least when the commenters make a mistake they’re not teaching others to make the same mistake, nor are they profiting from it.
The articles can be a great conversation starter even if the projects inside them are best held as an example of what not to do, but some of the projects are less defensible. Some of the ones that make the rounds portray themselves as a how-to video or at least an example to follow despite the creator knowing they’re only doing things that way to advertise for their sponsor, or they’re deliberately making dumb mistakes so they can earn more money after fixing them. It can be a losing proposition to extend good faith when criticizing someone who’s not acting in good faith. Mind you, that’s not nearly as common as rude critics are, but I find it worth pointing out anyway.
Ugh, but the ones who aren’t in good faith are *really* annoying and I feel for the mods/editors.
This is pretty cool. there is a real need for low end digital spectrum lookers to get people interested in the spectrum and understanding this stuff.
This is a very interesting approach. Debayering in software, and an AI slant, nice.