After building many small circuits to test a single component, I have finally found a neat little project to pit my Arduino up against; making absorbance measurements! This is really only the first stage, and I’m not sure how reliable the results will even be, but it’s sure going to be fun to try! The parts list is surprisingly simple:
- An Arduino
- Triple Output LED RGB ($1.95 at SparkFun)
- Light to Frequency Converter – TSL235R ($2.95 at SparkFun)
- A cuvette Holder
- a 0.1 microF capacitor
- Wires to connect it all together
Of course, an UV-Vis spectrometer is not a simple device, and we are going to have to make a couple “stretches of the imagination” here. For example, to measure the spectrum, we will need to scan over individual wavelengths. Since there is no monochromator listed in the parts, how are we going to do that? We’re going to fake it!
One of the reasons I wanted to build this, was to see how close I could get pulse-width-modulators to output light “at single wavelengths” with an RGB LED. Thanks to this neat little website, which contains a fortran program to generate the RGB levels for 780 to 380 nm, I have all the data I need to give it a quick trial. I used the code from this website to get my light-to-frequency converter running. Luckily there are a lot of clever people out there that put together some nice code to get these parts working already, and post it up online!
If you have ever seen a triple-output LED in action, you will know that it is really 3 LEDs in one, and therefore doesn’t produce a perfect mixture of the 3 colors of light; the further away you shine it at a wall, the larger the difference you will see in the red, green,and blue rings it casts. I tried to make the length between the LED and the detector as short as possible, and try and aim for the middle!



As you can see from the pictures above, there is hardly anything to this!

Since this is still test-mode, I used some card-stock and tape to hold it together for now; super classy!
At this point, having everything together, I didn’t think it was going to work all that well. Another problem I ran into was the intensity of the LED. This light detector seemed to freeze the program if the light became too intense; and since I have them maybe 2.5 cm apart, it’s pretty easy to overload the detector. I seemed to have remedied this by using larger resistors for the LEDs to limit the intensity. I need to investigate the effect of scan time as well. I didn’t have a cuvette handy at the time, so I took a piece of green plexiglass left over from my beowulf cluster and used that as my first measurement.

As you can see from the picture, is absorbs in the blue and red, and transmit light in the green area (green should be around 510 nm)! I scanned from 780 to 380 nm in 100 millisecond intervals (so about 40 seconds total). The plot of the empty cuvette holder shows some sharp peaks; I’m sure the sensitivity to particular wavelengths plays a part, as well as the RGB nature of the light source (among many other things, no doubt). Still, I’m amazed that it looks that good considering its made of $5 dollars worth of parts (not counting the arduino or the cuvette holder I had laying around), and that I took the measurement in ambient light.
Part 2 will come as soon as I get a cuvette to try some real samples in! I plan on building a sturdier mounting of the LED and detectors as well as making a little light-proof box for it. Once it’s all together I’ll post up my arduino code and a circuit diagram as well.
UPDATE!
I was having to much fun to leave this alone for another week. Despite not knowing how well this was going to work, I decided to invest a little more time in trying to get it as close to right the first time as possible.
A while ago I bought a heavy-duty pencil box to store some parts from a machine-shop class, and today it has been re-purposed.

What is wonderful about this box, is what will fit inside this box

In order to stabilize the LED, I bent a thin piece of aluminum around the cuvette block.


I used another small piece of aluminum to be a supporting back for the LED as well, all held in place with a couple machine screws. This can be done with a hand drill (which I did), but would go a lot better with a drill-press.

I drilled straight through in hopes of keeping the detector and the LED light source lined up.

Through some bit of luck, both the arduino and the breadboard fits inside the box with the cuvette holder and all the wires!

I put a hole in the back in order to snake the USB cable through.

Here we have it: a USB absorbance spectrometer in a to-go box!

I got a hold of some acrylic cuvettes, and what better to test a home-made absorbance spectrometer than with food coloring!

You can see the colorful cuvettes below (Water,Red Yellow,Green dilute-blue,dilute-green). I used water as a blank, and added 1 drop of food coloring for each sample. The green and the blue were too dark, and I had to dilute them down.



My first couple of runs ended rather discouragingly, however I found that a lot of the trouble came from the intensity-threshold of the detector. I changed the sensitivity, and gave it a whirl again.

As you can see from the picture above, the detector isn’t doing too well at at 650 nm and larger wavelengths. This could stem from from the larger resistors I’m using to limit the intensity, and/or the LED — detector are not aligned all that well for this region. Since it is this way for all samples, I will crop out that part of the spectrum for now. Looking at the sharp peak around 450 nm, wavelengths smaller than this may not be “usable” either.

Either way, the results aren’t too shabby for a home-made contraption like this! I have plotted -Log10(I / I0) where I is the intensity of the particular color and I0 is the intensity from the blank scan (water).
I have outlined some rough wavelength ranges for the colors in the plot range. You can see that I scaled the green and blue by a factor of of 2, which is a good sign since those were diluted more than the yellow.
We see that the yellow dye seems to heavily absorb in the violet/blue range while decreasing across the spectrum. This contraption would put it at more of an orange than a yellow
We can see that the blue dye heavily absorbs on the orange side, and there appears to be a minimum under 450 nm. This is in-line with expected results, but as mentioned, we may not be able to trust results at this wavelength and below. Either way, this would put this dye in the blue/violet range.
And the best result: Green!
It can be seen that the green sample absorbs more in the blue and orange sides, with a minimum in the middle. It looks like the minimum absorbance is just under 510 nm, right where it should be!
There we have it! All 3 cases seem to behave like they should, so I’m going to call this one a victory.
Todo:
- The “optics” need to be aligned better, to get resolution in the red-range
- Smaller resistors should be used to get a boost from the light source as well (I used 10K; maybe switch to 1K. I think the red may be too weak).
- The sensitivity level of the detector needs to be optimized as well. The dynamic (software) switching doesn’t seem to work so well, so one range that functions over the entire spectrum would be the best option. I have an IC version which should handle intensity levels on its own, but I haven’t played around with that one yet.
Sometime soon I’ll try and make some “accuracy measurements”. Perhaps dilutions of food dye, and see if I can get a linear trend. It would also be nice to compare a value with a reference. More to come!
Update!
I was thinking more and more about this today, and I just can’t believe that the RGB LED was working like premised above. When I bought all of these neat little electronic sensors, I also picked up a color sensor which would have been handy here. Now if you look at their product images, then I know what your thinking: “Why did they put a picture of this thing next to a giant US quarter?” Well let me tell you, they didn’t. It’s truly hard to appreciate how tiny this thing is until you either A) look at a quarter or B) see it in real life (guess which one I did first). If you’ve seen my 556 timer circuit, then you know that there is no way that I can solder this thing correctly by myself. So what else could we use to to analyze a visible spectrum?
That website has some wonderful directions on how to make a spectroscope out of things laying around the house. The directions are straightforward, and it will be hard (but not impossible) to mess up. I even happened to have an extra priority mail box laying around just like in their tutorial, so I won’t post up any images of it.
On to the show! YouTube cut-away
I stuck my webcam in the view-port of my spectroscope to record the video. You will notice a persistent blue band; this comes from a blue light that is permanently shining on my webcam (I can’t effectively cover it either). It does end up making a handy reference though. As you can see in the video, most of the spectrum is in there at one time or another, but there is nothing even close to the discrete wavelengths desired.
You can see the red being constantly on at first, which perfectly explains the flat line in the spectrum above “650 nm”. Then the green LED kicks in, with the red fading after a while, and then blue (which doesn’t show up well due to the webcam light). The trend in the spectrum above is only present because it effectively measured the absorbance of red, then green, then blue (which means (at best) it’s only accurate at the wavelengths of each LED).
Victory denied.
It was still a fun project! On the bright side, I’ve been looking for an excuse to build a spectroscope. Perhaps I’ll re-write the code to measure at 3 wavelengths (the R, the G and the B) and compare it to the Spectronic 20′s in the general chemistry labs. It’s also nice to have tested the light-sensor; I can use it to toy around with the actual monochromator I salvaged a while ago!