Project overview

I am tasked to develop a microprocessor based device that when shown a light upon, can determine the source of the light (Natural light, Flourescent Bulbs, LED Bulbs, Incandescent Bulbs, Flame - Forest fire). At this stage, only the visible light is considered.

From my research, the only way to differentiate the source of light is by analyzing the emission spectrum and matching it closely to known values. Example:

enter image description here

Solutions considered

Measuring RGB composition ratio of the light

I have considered going this route as it doesn't seem too complicated, smaller device, can be integrated easily into the bigger project as a forest fire detector and even suggested by my supervisor. But I have doubts that this would be very accurate as some light sources might have close values (the intensity is what is being measured on a ball park wavelength).

The sensor I am looking at currently is the Hamamatsu’s S10917-35GT RGB color sensor, sensitive to only the required wavelengths.

Building a high resolution spectrograph with a diffraction grating film

This route is much more complicated and requires external processing of the images to determine the light source. Basically, you build a spectrograph with a diffraction grating film and a high resolution camera. The image is processed with a computer software to plot the emission spectrum graph and you can analyse the graph to determine the light source. Development guide is here

Unfortunately, this is not very convenient as we would prefer the device's primary objective to function on it's own without any networking.

So, the question

  • Is there any drawback on my first solution?
  • Is there a better solution? Preferably can fit on a standalone device?
  • This would probably be far fetched but is there a sensor out there that can analyse a light emission and provide intensity values on a range of chosen wavelengths? Or atleast something that would help me build a device that does such.
  • \$\begingroup\$ Links to the missing hyperlinks below (needs a higher reputation to post more than 2 links) [1]: comsol.com/blogs/… [3]: hamamatsu.com/jp/en/product/alpha/R/4153/S10917-35GT/index.html \$\endgroup\$ – Spikes Oct 14 '16 at 14:50
  • 1
    \$\begingroup\$ I don't believe the first solution will work. I would go towards the analysis of the frequency and/or the waveform shape (I am assuming we are speaking of AC powered sources?). Obviously daylight is DC. Fluorescent and incandescent will have different waveforms. But I guess you will need to conduct some experiments with different approaches. \$\endgroup\$ – Eugene Sh. Oct 14 '16 at 14:53
  • \$\begingroup\$ An alternative to processing the spectrograph with a camera is to place an array of sensors directly in the locations where the spectrograph is projected. These sensors would be non-selective photo-detectors (respond to a wide frequency range). You wouldn't be able to achieve high precision like this, but it might suffice for measuring color temperature and CRI, which should allow you to differentiate different types of light. I have never done anything like this. But it could work. Would require a bright light source. \$\endgroup\$ – mkeith Oct 14 '16 at 15:40
  • \$\begingroup\$ @EugeneSh. Yes, exactly what am thinking, i.e analyzing the waveform shape would be the better route. The only problem is that we'll need to analyze the image with a computer program so the device cannot determine the light source on it's own (at least at the size we need it to be) \$\endgroup\$ – Spikes Oct 14 '16 at 16:15
  • \$\begingroup\$ not necessarily. You can start with a frequency-domain analysis (Fourier?) and see the unique patterns. \$\endgroup\$ – Eugene Sh. Oct 14 '16 at 16:16

You really are looking for someone who's already solved this, I suppose. But I don't know of any project, myself. So all I can offer are some thoughts to consider.

On spectrometers:

  1. For a spectrometer device, a DVD-RW (don't use DVD-R, as it will absorb substantial bands in the red region) provides 1350 \$\frac{\textrm{lines}}{\textrm{mm}}\$, so that is very cheap and readily available.
  2. Small megapixel digital cameras are also cheap. An array could also be used, but these days it seems an entire 2D camera is cheaper and more available. So I wouldn't bother with an array.
  3. Using a DVD-RW you can actually separate the yellow spectral lines of mercury at 577 nm and 579 nm. (Not with a CD, though.) I've done this, myself, using a DVD-RW and a mercury-argon lamp.
  4. Wavelength calibration is cheap. Just get a mercury-argon lamp. You'll get the argon lines in the first minute or so, then the mercury lines will dominate later. From the combination of them, you can easily calibrate your camera pixels vs wavelength. Hg-Ar lamps used for calibration used to cost me about $8, but I expect they are more expensive now.
  5. Intensity calibration is expensive. You need a standard lamp, traceable to NIST standards, and these have to be recalibrated after 100 hrs use, or so. They are cheap bulbs, uncalibrated. But the calibration process costs real money. Then you have to set up a proper optical arrangement, too. But this is the only way to figure out just how each of your pixels respond to each of the wavelengths they are being hit with. Frankly, I'd try and avoid any of this and hope I didn't need it or could just apply a basic templated approximation of a standard lamp and not waste money on actual calibration, hoping that what I got was good enough. Or just not bother at all and use a rigged up equation and figure, "oh, well," and see how it goes. Chances are, you can make this step go away and still get useful results if you just think carefully.
  6. You probably can consider going from 450 nm to 750 nm, but you cannot hope to exceed an octave with a single grating. You may want some kind of filter involved so that you don't get mixed up spectral energies on the same pixels. Or just don't worry about it and do some experimenting.
  7. Optical baffling will be desired to avoid getting extraneous light where it isn't wanted.
  8. Tony just reminded me... you'll need a narrow slit -- about as narrow as you can make it. I prefer the use of two old-style razor blades that can be adjusted. One fixed, one movable. But for the card stock paper box, I just used an exacto blade 'very carefully' to create a narrow and uniformly narrow slit.

I've done all this using a sheet of paper (card stock) that I print out and then cut, fold tabs, use Elmer's glue, and create a box with baffles made essentially out of paper. The baffling uses special dark flocking to help absorb and block wayward light. The DVD slides in at the correct angle and a small camera is then placed at the exit. I've used this with my own eye to observe different lighting in the house and it works PERFECTLY well, in my opinion. I have no trouble differentiating between incandescent, fluorescent, and LED lighting sources. And the sun, for that matter. I tried a DVD-R and immediately saw a huge missing band in the red, which is why I'm telling you that you need DVD-RW if you care about that region.

I could publish some plans for all this, I suppose. Location of slit, angle of DVD, etc. While my box design uses the entire DVD-RW (because I wanted to be able to drop in other DVD media and/or a CD (at a different angle so I'd made two different insertion slots for that purpose), only a tiny part of the DVD-RW surface is actually involved (if baffled correctly.) So I also liked using the entire DVD-RW for that reason, as well, because cutting the DVD into pieces would stress it and I didn't want to do that, either.

Just by way of a little info, the box used a 70 mm vs 40 mm tilt for the DVD (1350 \$\frac{\textrm{lines}}{\textrm{mm}}\$) and 50 mm vs 40 mm for a CD (625 \$\frac{\textrm{lines}}{\textrm{mm}}\$.) The slit was positioned on the 40 mm face, positioned about 10 mm from one edge in either CD or DVD case.


The RGB sensor you mentioned has, as I expected to see, very wide acceptance of wavelengths in each of the three sensors. LEDs tend to have very wide response ranges (they emit and receive over a wide range of wavelengths.) That sensor has modestly overlapping responses. How well all that will work for you, would be a matter of experimentation, I think. You could apply some computer code, instead, using your curves and the response functions of the sensor to see if it would be serviceable. But I'm not going to even try and write it for you. Perhaps the best thing would be for you to knuckle down and buy the sensor and do some testing with it. It may be just fine for your needs. But I can't tell you yes or no, from a quick scan of it. I also haven't tried to do this with RGB, so that's another reason I can't promise anything here and you'll have to just try it for yourself.

I liked Eugene's comment about frequency, too. Incandescent bulbs (and I've tested this using a very sensitive instrument -- with tens of microKelvin resolution and hundreds of microKelvin accuracy traceable to NIST standards, as I work on such things) will vary about 3% of their amplitude during the AC cycling at 60 Hz. (Would be different with 50 Hz.) Fluorescents operate at mains frequencies and also at high frequencies (both are manufactured and used.) But their emissions are through phosphors, which often have fast response times. (Some phosphors are slow, order of millisecond taus due to depending upon forbidden triplet to singlet transitions. But many of them are quite fast -- microsecond taus.) You may have to do some experimenting here. But I think this could be fruitful, because you can design electronic circuits for very narrow bands if you want to. You'd have to worry about conditioning the signal so that you don't saturate the amplifier chain. But that's doable. I haven't looked at the frequencies used in modern LED bulbs, though. And I'll leave it to you to google up details there. All that said, I think Eugene's point has merit worth examining, as well.

Personally? I'd go with the DVD-RW because I have a lot of experience with doing that, know that I can do it easily, quickly, and cheaply, and because I think I could avoid the intensity calibration step to get where you need to go. The cameras are dirt cheap and so is the Hg-Ar lamp for wavelength calibration, periodically. It's almost no work at all. Plus, I already have walked around the house checking out different light sources with a hand-held card-stock box with no electronics at all and was perfectly able to see the differences in various light sources, by eye. So I know I can get there from here.

EDIT: A couple of images from an old fluorescent bulb. One of them across the spectrum and the other zoomed up a bit. Pretty cool separation of the mercury doublet there! whole spectrum zoomed up

I specialized in binning LEDs for Siemen's OSRAM division years ago, as a contractor. So this stuff comes partly from that experience. We first used expensive spectrophotometers, but switched to Ocean Optics some time later (much cheaper.) But in the meantime I had a lot of fun with DVDs and CDs, used with all that fancy calibration equipment laying about. (Including disappearing filament calibrators, which I forgot to mention above.) Spent a LOT of my time studying human response reports prior to and since the CIE 1931 standard and the later ones in the 1960s. Also really enjoyed Edwin Land's work in the late 1970's and early 1980's -- very interesting stuff.

  • \$\begingroup\$ +1 for a fascinating and relevant read. Lots of good leads to follow from here. Nice one. \$\endgroup\$ – Wossname Oct 14 '16 at 16:19
  • 1
    \$\begingroup\$ @Spikes Just read up on gratings, I think. But a single grating can not disperse more than one octave in wavelength without mixing up the spatial positions from higher orders. \$\endgroup\$ – jonk Oct 14 '16 at 17:53
  • 3
    \$\begingroup\$ @TonyStewart.EEsince'75 Interesting. I worked on using LEDs as standard candles. Obviously, they have to be heated up and held at a constant temp. The 48 hour bake-in period found and eliminated about 99.4% of them. Only a few settle down enough to really be good. Most just flitter around. And this is with 0.1% precision current sources. Most LEDs aren't much good for this. Yet people seem to imagine that if the current is controlled well, the LED emits consistently. Nope! \$\endgroup\$ – jonk Oct 14 '16 at 18:55
  • 2
    \$\begingroup\$ I'm not sure I understood the geometry of the self-built diffractor with DVD and paper baffle. An image maybe? Thanks \$\endgroup\$ – FarO Oct 15 '16 at 9:57
  • 2
    \$\begingroup\$ @OlafM I'll have to draw up something, then. I'll try and do that at some point today or tomorrow. \$\endgroup\$ – jonk Oct 15 '16 at 16:04

I'm going to agree with jonk, but suggest a simpler method of identifying sources.

Build a spectrometer with camera (using a DVD or other diffraction grating.) Make it mechanically solid so that the camera, the grating, and the screen can't move in relation to one another.

Don't bother with calibration - at all. You will also want to disable automatic white balance in the camera and use a fixed white balance.

Expose your detector to examples of the different light sources you want to detect, and record the images.

Now, you can use your pick of signal processing methods to detect which of your stored spectrograms most matches the current spectrogram.

OpenCV or Gnu Octave or SciPy all present workable methods to detect similarities.

  • \$\begingroup\$ Yeah, should work. But wavelength calibration is so dirt easy, I'd do it anyway. \$\endgroup\$ – jonk Oct 14 '16 at 16:41

Lots of great answers here already, but to provide some specific comments to your final questions:

Is there any drawback on my first solution?

The drawback is that you only have three datapoints (r,g,b) to judge the color, and, depending on the different light sources you are trying to distinguish, you might not be able to tell them apart. This is the same problem that a digital camera encounters when it tries to set the white balance, and sometimes, the camera guesses wrong and the colors of the photo are distorted. However, if you allowed a digital camera to image a known object, like the same white piece of paper, then it would likely be able to distinguish the source of the light most of the time.

is there a sensor out there that can analyse a light emission and provide intensity values on a range of chosen wavelengths?

A grating (or prism) based spectrometer does exactly that; it provides the light intensity as a function of wavelength.

Alternatively, if you want just a few sensors, you could simple take a silicon photodetector and place the appropriate optical filter (colored glass) in front of it to only allow the wavelength range of interest to pass to the filter. An advantage of this approach would be that the single photodetectors could likely operate more quickly than an array detector, and may allow you to look at the temporal structure of the light and spot characteristic patterns, such as the 60 Hz fluctuation of a lightbulb or the rapid flickering of a flame.


You do not have to build your own spectrometer, devices are already available off the shelf, like this ultra compact C12666MA from Hamamatsu.

The 15 nm spectral resolution could be just fine for this task.

It is also a good idea to tell DC and 50/60 Hz apart, maybe with a separate sensor.


Cameras work so some extent exactly the way you show the RGB sensors. If you had had experience trying to capture saturated colours of LEDs in high density light, you will understand it's limitations, but for broad spectrum photo's as we know it works fine.

It depends what you want to measure.

For example white light is just our perception of RGB sensors in our eyes and incident light can fool us into think daylight white is just the balance of Blue and yellow-red phosphor converted light so that the peaks are equal (when converted to CIE eye correction levels)

But the reality is quite different when we compare a Halogen source on a broad pallet of reflected colours and compare with a daylight 4500-5000'K 81% CRI White LED. Now the colours look different due to the missing spectrum in the source.

For accuracy, your only hope is a calibrated diffraction method instrument. For rough eyeball incident colours reflected off gradient scale paper with a full colour gamut, an RGB camera will work. close enough with a calibrated RGB sensor/detector unit and software. But this is not how they do it in industry, but that's basically how paper scanners work with internal RGB + B/W calibration before the scan begins.

Professional light spectrum analyzers measure x,y , u,v and many other parameters of white light.

  • \$\begingroup\$ I have always used the Microsoft boot "retro" waving RGBY flag to eyeball the display colour balance and measure the symmetry of the corners to see if the display was out of calibration, but now use DPT.exe to calibrate the whole gamma range for ideal balance and BW saturation levels using video toolbar for card to calibrate TV and 1080p monitor colours \$\endgroup\$ – Sunnyskyguy EE75 Oct 14 '16 at 16:59

Thus is an old question, and I wonder what was the solution, but looking through the answers I am quite surprised not to see a rather obvious solution.

First, you don’t need to analyze the whole spectrum. Just sample it in a way that maximizes the separation of the sources. Given that you have relatively few sources you can do this by eye, or actually run a PCA or ICA analysis on a discrete version of the expected spectrum. Once you have selected a handful of spectral regions you can proceed.

Second, I would seriously consider the infrared region. Primarily because a fire would have abundant emission there, but most importantly because sensors in this region are very common.

Third, select a discrete sensor or sensor/filter combination that provides you with good enough spectral response in your first desired band. Note that there are many inexpensive filters, photodiodes, phototransistors, and PIR devices that can be selected by wavelength (even single-color LEDs can work in a pinch).

Fourth, if you are doing this mathematically, project your expected responses into the response of the sensor/filter and subtract it away so that you can repeat the procedure with the next significant band. If not, just overlap and estimate what region is next.

Note that filters can also be used to remove bands. If two sensors cover the perfect area, but their responses have too much overlap, subtracting the overlapping band would increase their discrimination. .

After repeating this two or three times, you will have a small set of inexpensive sensors that you can use. Put some circuitry around them, and calibrate your response with a few known sources. If you did the separation correctly, you will only need a rough calibration for the sensitivity of your filter/sensor/circuitry design.

This is basically the RGB sensor idea, but using properly tuned wavelength bins instead of rather arbitrary ones.


If you don't need very high radiometric sensitivity, collimate it, run it through a grating, and dump the image on a linear sensor array. Analyzing the spectrum is easy if you have a microprocessor. The temporal variation alone isn't likely to work very well since consumer lighting systems vary widely in flicker frequencies. The only things that will be hard to distinguish from the spectrum are the incandescent and flames. You might use the temporal variation for that, working under the assumption that the flame will be pretty random and the incandescent should have a distinct 60 Hz component. Beware though that electronics have a tendency to pick up stray 60 Hz, so you'll have to make sure you're seeing 60 Hz light and not 60 Hz noise. The linear sensors are a cheap and simple part that you shouldn't have any trouble interfacing. The only way I could see this working with 3 channels is if you were only trying to classify the flame and you could dump all the other light sources into a "don't care" pile. In that case, you can pretty reasonably take anything with, say, way more NIR than blue emission to be either incandescent or flame. If you're willing to work with MWIR detectors, you can skip the temporal variation and just look for the CO2 emission peak though. The incandescent shouldn't have that. That's what a lot of commercial sensors use.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.