Introduction: An Inexpensive Photometer and Colorimeter
What is this instructable about?
The aim of this project was to construct a simple and inexpensive device that allows the measurement of the color composition of a solution, i.e. a colorimeter, and/or its optical density, i.e. a photometer.
It is intended be an educational tool for science classes, but it might be also be used by hobby scientists, citizen science groups, and probably for a multitude of other purposes.
To read the data from the sensors, the unit it may be either be connected directly to a Raspberry Pi or, via an Arduino, to a PC.
The estimated total cost for all parts required are in the range of 30 € or US$ (w/o shipping costs).
As you can use a Raspberry Pi Zero or Arduino Nano, the additional costs can also be very limited.
The layout of the housing allows to build both photometer and colorimeter from the same parts, just depending on the sensor breakouts and LEDs you will use.
So what can you do with the device?
A photometer allows to measure the amount of light reaching a sensor. Given you are using a constant light source, and you place a translucent object between light source and sensor, this allows you to calculate the amount of light that gets lost on this way. This defines the optical density of the object. The "lost" light could either be absorbed by a dye, or scattered by particles, or a combination of both. So a photometer allows to quantify the optical density of a clear solution, e.g. some ink, or a suspension, like milk or yeast particles in beer, wenn filled into a standard photometer cuvette.
A colorimeter allows you to measure the color composition of an object, here of a solution. The sensor used here for the colorimetric device splits the visual spectrum into three channels, red, green and blue (RGB), hereby simulating the way our eyes see colors. For most colors this allows to describe our impression of a color by a combination of three numbers describing the intensity in the three RGB channels, typically defined in 256 steps. So black is 0-0-0, white is 256-256-256, pure red 256-0-0 and so on. Pure yellow would be 256-256-0, pure cyan 0-256-256. But the sensor used here is very precise and allows to discriminate over 67,000 steps for each color channel.
Photometers are often used to measure chemical reactions, like changes in the acidity (pH) of a solution, by measurement of the intensity of an indicator dye. For optimal detection you may want to measure only the absorption of light close to the absorption maximum of the dye. Therefore you will prefer to use a monochromatic light source instead of white light. LEDs come in a wide variety of colors, give nearly monochromatic and intensive light with a very stable intensity pattern and are very energy effective. The sensor used for the photometric layout allows you to measure light intensity over a very broad spectrum, from UV to IR, with a very high precision.
A variety of indicator dyes are changing their color, e.g. from yellow to blue. Here a colorimetric measurement can allow to demonstrate and quantify this transition process, as the colorimeter described here could also be defined as a three-channel photometer.
So you may for example measure the pH, oxygen and CO2 concentrations in your pool or aquarium, or nitrate and lead concentrations in your drinking water. Or just analyse the precise color of your favorite ink, so you may paint your flat in the same color.
As the costs per unit are extremely low compared to any commercial devices, it is a nice tool for science classes and hobbyists.
Step 1: Basic Layout of the Device; Required Parts
The device consists of three core elements:
- the housing and lid are made by assembly of pieces that were laser-cut from a single sheet of 3 mm acrylic (see pictures next step). They are defined by a single SVG-file. I am using the laser cutting service of Formulor (Berlin/Germany, 13€ per plate plus shipping), but using the same SVG-file, the parts could also be ordered at Ponoko (US) or RazorLAB(UK) at a similar price. You may choose from a wide variety of colors, but to minimize color artefacts I would recommend black, grey or white.You can find the SVG-file defining the latest tested version at a later step of this instructible.
- a sensor breakout:
* For the colorimeter, the TCS34725 RGBW-sensor breakout from Adafruit (< 8 US$/€, www.adafruit.com/products/1334) is used.
* For the photometer I use the TSL2591 breakout from Adafruit (< 7 US$/€, www.adafruit.com/products/1334) .
I ordered both breakouts at Flikto, Germany.
- a light source:
* For the colorimeter I am using a 5 mm naturally white LED with a narrow emission angle (Nichia NSPW500DS, about 2,20 € at Conrad, Germany). Please be aware that a "white" LED does not give a homogenous emission spectrum, as sun light, but a sharp blue peak and a bell-shaped emission spectrum with a maximum in the yellow-green range (see image). "Naturally white" LEDs emit similar amounts of light in the red, green and blue regions.
* For the photometer, a 5 mm LED with a color optimal for the specific analyte shall be used.
E.g. for a dark red analyte, you may use a green LED, a yellow LED for a blue dye.
You can find an overview of some commercially available LEDs with different colors at a later step.
The 5 mm LEDs can be powered either by a two 1.5 V batteries or using the 3.3 V output of the Raspberry Pi. Most yellow, orange and red LEDs will need a series resistor (e.g. 60 Ohm) to reduce the voltage to 2.1 V.
In addition to the above, an assortment of screws, nuts and washers (2.5 M and 3 M), silicon rubber feet and some cables are required. I also would recommend to use a breadboard to connect RPi and device.
A more detailed list is found at a later step.
Step 2: Assembly of the Device
The parts for the housing are constructed in a way that they fix together precisely, with grooves and tongues, without gluing. Only the assembly of the lid requires a bit of glue.
The pictures shown here may not represent the latest version of the device, as its layout still is subject of ongoing optimization.
At first remove the laser cut pieces from the acrylic plate and remove the protection foils from both sides of all pieces.Then try to stick the pieces together, to ensure that all fits well. First connect the central elements with the back and front walls, then add the right and left side pieces. Now try to place this on the base plate and to stick the tongues into the holes of the base plate.They should fit perfectly, but there can be minimal differences in material thickness. So in case you may need to break the edges a bit with a file or sandpaper, just until the pieces fit. Now place the side walls of the cuvette chamber and make sure they fit as well. Now disassemble the pieces again.
As a next step assemble the sensor unit. Solder the header to the breakout, according to the instructions found at Adafruit ("Learn" on the product specific pages). Now fix the cables to the ports. Make sure to write down which cable is connected to which port (Gnd, Vin, SCL, SDA; LED).
Alternatively you may solder the cables directly to the soldering ports.
At next fix the breakout to the sensor holding plate using two 2.5M screws, nuts and washers. Depending on the sensor you are using, you may have to turn the sensor holding plate. Adjust in a way that the sensor chip is placed exactly behind the rectangular hole, then tighten the screws.
Now stick two nylon M3 screws through the holes in the inner wall element and at the distance piece. Then stick the sensor holding plate onto the screws, allign the placement of the rectangular holes and fix the position with two other nuts.
Now assemble the LED unit. Stick two Nylon M3 screws through the holes of the second inner wall element. Stack the three LED holder elements on the screws, then place the LED into the resulting central hole. Now add the LED fixing piece and fix the stack with two M3 nuts. Make sure that the LED is properly alligned before you tighten the nuts. Connect the cables to the LED. The longer wire is "plus", the shorter "ground". To check functionality and optimal allignment, connect the LED with your power source, in case adjust the allignment.
Now assemble the "photometer box" as you have done before. First run the cables through the holes in the back plate.Then stick the tongues of the two plates with sensor and LED into the holes of the back plate, add the front and side plates and place the box on the base plate.
I would recommend to place four small silicon rubber feet on the botton of the base plate.
!!! Do not glue the box, as you may not be able to disassemble it any more !!!
I recommend to fix the box it with a some adhesive tape, if required.The most recent, but yet-to-be-build layout will simplify assembly and fixation of the structure even further.
Finally assemble the lid. Glue the two pieces defining the lower edge to the lid plate. Then glue the handle to the center of the lid plate.To reduce reflection, you may add a piece of self-adhesive felt to the inner side of the lid.
Connect the cables to the corresponding ports of your breadboard, PI or Arduino and check for functionality of the sensor and LED.
Step 3: Setting Up the Raspberry Pi; Required Software
As both sensors are communicating via I2C, you will have to activate this on your Raspberry. In addition you may need to install the appropriate drivers/kernel support. As you can find very good and detailed instructions on this at the Adafruit website (Adafruit: GPIO/I2C setup), I will not describe this here in any detail.
If you succesfully have implemented I2C on the Pi, connect the sensor with Ground, Vin (I use 3.3V) SDA and SCL. In the case of the RGB sensor you also need to turn off the build-in LED by connecting the LED line with Ground. Check if the sensor can be found by entering "sudo i2cdetect -y 1" at the shell.
Unfortunatelly both sensors are using the same I2C adress, 0x29, so you can't use them in paralell.
Now you need to install some software to perform your measurements. Luckily Python programs to read the data from the sensors were already available, so I only had to modify the TCS34725 software provided by Adafruit (https://github.com/adafruit/Adafruit_Python_TCS34725) and the TSL2591 software by "MaxlKlaxl" (https://github.com/maxlklaxl/python-tsl2591 ) a bit to adjust them for my purposes. I like to thank both of them for their brilliant work.
In the accompanying software package you will find examples of programs that will allow to perform measurement series and kinetics with both sensors. As I am rather new to Phyton programing, the programs require some optimization, I appreciate any help. Depending on your light source and your specific application, you may need to change the data sampling time and/or sensor gain settings of the sensors.
White, UV, blue and green LEDs run at about 3.1 V, so you may power them directly from the Pis' 3.3V output. For yellow, orange and red LEDs you need a series resistor between LED and power, otherwise they will be distoyed. If you do not want to run the LEDs permanently, you may connect them to a GPOI and switch them on and off by software.
So far I have not performed any experiments with the Arduino or Trinket, but Adafruit provides libraries and scetches for both sensors.
Step 4: Performing Measurements
The device is built to measure aqueous solutions or suspensions by placing a standard photometer cuvette between LED and sensor. I am using disposable cuvettes made from polystyrene (PS) or acrylic, and both full volume and semi-micro cuvettes work. You may get 100 such cuvettes for about 12- 20 €, depending on type and material, and you may use them several times.
So basically fill a sufficient volume of the solution/suspension into the cuvette, place it in the device watching for correct orientation, close the lid and start to measure. Given you are using a Raspberry Pi, you will have to start a Python program that allows you to perform the type of measurement (single, multiple, kinetic) you like to. Some of my programs write the data to so called CSV (Comma separated values) files you may open with MS Excel or LibreOffice Calc, Word or Writer and several other programs. This simplifies subsequent data analysis and documentation.
I have also written a simple Pygame script to show the color defined by the measured RGB values on your computer screen, so you may compare the actual and the measured colors. For various reasons they might differ a bit.
Make sure that the dye concentrations are not too high. Be aware that e.g. a bright blue solution might already be pitch black under the light of a yellow or red LED.
Step 5: Example #1: Kinetics (colorimeter and Photometer)
So far I have performed only a limited set of measurements.
An example for a kinetic measurement is the slow evaporation of carbondioxide (CO2) from sparkling water placed in an open cuvette. For this purpose, a bit of bromothymol blue was added to normal water and a small volume of CO2-enriched, "sparkling" water was added until the color changed from blue to yellow. Now the kinetics measurement was started and measurements were taken every 20 minutes for several hours. The data was automatically written to a CSV file and later analysed using LibreOffice Calc.
So what is happening? By addition of carbon dioxide to water it gets acid. As the concentration of CO2 in air is much lower than in the water, it evaporates slowly from the water, which results in a rising pH. In an acid solution bromothymol blue is faintly yellow, while under basic conditions it is bright blue. Around pH 7.0, the pKa of the dye, the color of the solution is green, due to a mixture of yellow and blue forms of the dye.
Using the RGB sensor, it is possible to detect the decay of the yellow form in the blue channel and the increase of the blue form in the red channel, while the effect on the green channel is only moderate. As you can see in the chart, over time the absorption in the blue channel decreases (i.e. less yellow dye) and the absorption in the red channel increases (i.e. more blue dye). As expected, the color changes over time indicate an approximate first order decay kinetic, values asymptotic nearing maximum or minimum values
The same process has also been measured with the photometer. The sensor gives you two values: a full spectrum value (Full) and a value of a second incorporated sensor which measures only the infrared (IR) part of the spectrum. The values of the visible part of the spectrum (VIS) can be estimated by subtraction of IR from Full values. The dye used here was phenol red, which is yellow in acids, red under neutral and violet under basic conditions. Its pKa is also around 7.0. The light source used here was a green LED, so the increase in "redness" resulted in a diminished amount of green light reaching the sensor.
Step 6: Example #2: Dilution Curve (photometer)
The second example is a dilution curve of a red dye.
As shown in the image, a serial 1:2 dilution was set up, with an additional blank value. The dilutions were measured from the lowest to the highest concentration, using the photometric sensor (TSL2591) and a green LED (Nichia NSPG500DS) as the light source. The measured values were written to a CSV file and analysed using LibreOffice Calc.
The resulting lin-log graph (linear: absorption vs. logarithmic: concentration) gave the typical S-shaped curve seen in such measurements. At low concentrations there is a direct relationship between concentration of the dye and absorption of light, while at higher concentrations it is asymptotically approaching a maximum level (total absorption). Using the curve, the usable detection range can be estimated to cover about two logs (100x) of concentration, which is reasonable for a photometric device.
Step 7: Some Final Remarks
- To make the devices described here available to the public, we are planing to place a optimized, checked and proved layout file for the acrylic parts at Pokono, so you may download it there for a small licence fee. I would like to insert a few changes to the current layout, which may require a few weeks to be evaluated.
For all that want to start right now: A slightly modified version of the last evaluated one is available at Ponoko.
The licence fee for the layout shall be used for this project, as I would like to give a number of the devices for an evaluation to schools or other other educational institutions.
- But as collecting all the required parts from different sources could be a hurdle, we think about setting up a small project to offer DIY kits that would alredy contain all parts, except for the Raspberry Pi, plus some cuvettes and consumables, so you may built your own device within a few minutes and start immediately with your first experiments.
So you might see a kickstarter project on this soon, and if you are interested in such a kit, please check this site again in late May.
- The part that may require the largest improvements is the software. I would appreciate if some skilled programmers would check my Python scripts and improve them. I would like to place links to your improved scripts in here, for public access. Please be aware that the basic scripts are licenced by Adafruit under the MIT licence, so any derivate should be as well.
- In this instructable I have used a few graphs taken from Adafruit and the data sheets of the sensors.
But there are also images I have copied from the web, but have lost the information from which sites. I would like to apologize for this and thank the owners of the images.
- If you like this project, please have a look to my other instructable on a Raspberry Pi-based microscope (Raspberry-pi-microscope ). The project got stucked a bit in the last months, as I have a busy full time job and a family, but may see some new developments soon.
- If you have any hints, suggestions or corrections, please let me know.
Step 8: Materials Required; SVG File
Raspbery Pi or Arduino
Adafruit TSL2591 breakout (for photometer, product ID 1980)
Adafruit TCS34725 breakout (for colorimeter, product no 1334)
You may use other sensors or breakouts, but you may have to modify the position and size of the holes in the sensor holding plate.
The acrylic pieces for the housing:
The current layout was optimized to allow all parts to come from one 181x181x3 mm plate that can be ordered at Pokono/Formulor/RazorLab. You will find the required SVG file of the latest evaluated version above.The attached PDF file illustrates the layout.
If you use another laser cutting service and/or plate size, you may have to rearrange the pieces so they fit to this format. You may use Inkscape to modify the layout of the SVG-file.
To ensure a clean snap-together of the parts, the material thickness has to be 3.0 mm precisely. I would recommend not to use materials with surface modifications, as they may be a bit thicker.
5mm LEDs, the topic has been discussed in detail in another section. For colorimetric applications use a neutral white LED.
Screws, nut and washers:
- Four M3 x 20 mm screws and four M3 nuts. I am using nylon screws, but brass or steel would work as well.
- Two M2.5 x 10 screws, two M2.5 nuts and four plastic M2.5 washers to fix the breakout to the sensor holding plate. The washers act as distance pieces and have to be made of plastic or cardboard. Do not use metal washers, as they may come in contact with electronic parts of the sensor breakouts and cause shortcut and damage!
I am using jumper cables to connect breakouts and LEDs with the breadboard or the header of the Pi Zero. In the first case female/male in the second case female/female cables are required. They should be sufficiently long.
Silicon rubber feet:
I add four small self-adhesive pieces of silicon rubber as feet below the base plate. You may get them at the next hardware store or use something else.
- A few drops of glue to assemble the lid. Any kind of plastic glue or super glue should work.
- A bit of adhesive tape, to fix the housing. This allows you to stabilize it but to change sensors or LEDs later.
- Standard plastic photometer cuvettes.
Step 9: Additional Information: LEDs
Emmision maxima of some commercially available bright 5 mm LEDs with narrow emission angles. Please notice that this are only suggestions, as only a few of them have been experimentally validated with the device.
These LEDs are blindingly bright, to avoid to look directly into the light beam!
UV: Nichia NSPU510CS, 375 nm (3.3 V)
5004PCH02, 405 nm (3.5 V)
violet: YDG-504VC, 412 nm (3.5 V)
blue: Kingbright L-53MBC 455 nm (3.4 V)
Nichia NSPB500AS, 470 mn (3.2 V)
cyan: Nichia NEPE510JS, 495 nm (3.1 V)
green: Nichia NSPG500DS, 520 nm (3.2 V)
yellow: Yoldal YZ-Y5N15N, 590 nm (2.1 V)
orange: Avago HLMP-EH1A-Z10DD, 615 nm (2.1 V)
red: Kingbright L-7113SEC-H, 630 mn (2.1V)
Red, orange and yellow LEDs may require a 60 Ohm resistor to reduce the voltage from 3.3 to 2.1 V (@20 mA).
UV and violett LEDs are out of the range of the sensors, but might be used for fluorescence experiments.
Step 10: Software
Here you find my recent versions of the programs for the colorimeter.
TCS34725 RGB Bradspi ...py is a modification of a script developed by Brad Berkland. All credits go to him, the ugly part is mine. (http://bradsrpi.blogspot.de/2013/05/tcs34725-rgb-color-sensor-raspberry-pi.htm).
My script is asking you for a name of the sample, then read the values and tries to translate them into RGB values. For optimal RGB calculation you need to enter to enter blank (water/buffer w/o dye) values measured previously into the code as reverence values. At the start and the end of the measurement it is asking you if you like to stop measuring, "Y" stops.
The other three Python script are based on a recently released script for the tcs34725 by Adafruit.
You need all three in combination. The script allows to perform slow kinetics. You must enter the name of the sample, the number of measurements and the time, in seconds, between measurements. Results are written, with a timestamp, to the shell and to a CSV file.
Any hints, improvements, corrections are welcome.
The scripts for the TSL2591 will be added later.
1 Person Made This Project!
- Dr H made it!