When I was working on the “FOSCAM FI904W IP-Camera IR Light Modification” project (see post below) I acquired three bags of Light Dependent Resistors (LDR). I purchased them direct from China because they were so inexpensive – a bulk package was only slightly more than the domestic price of just a couple of LDRs. The types are GL5528, PDV-P9005, and MJ5549. The GL5528 LDR purchase was special because it was an assembly, exactly as used in the Foscam cameras – including the LDR, an infrared blocking glass filter and a rubber housing.
One thing that I noticed with these cheap LDRs was that there were some in the bag that didn’t quite perform correctly. In other words their response to light didn’t match the device specifications. Now if I was going to ever use the extra LDRs in future devices, or sell them, I needed to test each one for specification compliance. Not owning any fancy, specialized LDR testing equipment, I decided to fabricate one with an Arduino.
The circuit above is the Arduino portion of my test hardware (I used a nano, not the uno shown). The circuit is very simple, with two parts. Arduino port A0 uses PWM to drive the 2N3904 transistor (filtered with a 10uf capacitor) which, in turn has sufficient current capability to drive the LED which shines on the LDR under test. The Arduino script steps the LED through increments of brightness. The second part of the circuit is the LDR. The Arduino reads the voltage drop across the LDR on Arduino pin A0.
For my first test set-up, I used a $1 white LED book light that I purchased at the local Dollar-Tree store. The photo below shows the test set-up – the LED shines directly on the LDR below. This was a total failure! Even with the room lights turned off, there was enough ambient light from the computer screen, and other sources, to screw up the tests – plus, with the room lights turned off it was hard for me to see what I was doing. Time for plan B.
I made another trip to the Dollar-Tree store and purchased a $1 while-light flashlight. I disassembled the flashlight and salvaged the round printed circuit board with three white light LEDs configured in a 5-volt configuration. Perfect! Next I needed a test chamber that would permit testing even with the room lights on. I raided my closet and salvaged a show box that would serve as my test chamber. I drilled holes in each end – one for the light and the other for the LDR being tested. After soldering wires to the white light LED assembly and to a test socket for the LDR, I was ready for testing. The shoebox test chamber is shown in the composite photograph below, sitting on my messy desk. The lower left part of the photo shows the flashlight white-light LED assembly hot-glued to one end of the box. The lower right part of the photo shows a LDR inserted into the hole on the other end of the test chamber.
The software to do the testing consists of two parts. Part one is a script running in the Arduino that submits the LDR to controlled light levels while measuring the subject LDR and sends the results out the serial port. The results are structured for subsequent use by gnuplot on my Linux desktop. The second piece of software is a shell script on my Linux desktop that reads the initiates the Arduino test, reads the data over the Arduino serial port and, upon completion, presents a visual represention of the LDR response curve as a line graph.
Before I finalized my tests I did some manual testing on the LDR using a different Arduino test script that permitted me to manually set the light level and take readings. Using this set-up and a Weston Master II light meter and a VoltOhmMeter (VOM) I characterized the GL5528 with candlepower per square foot and resistance. Note that the VOM does not measure above 2 megohms nor does the lightmeter read below .1 foot-candles. The measured data is shown in the chart below, which is useful to compare to the Arduino’s port A0 and A1 values used in my actual tests. The resulting curve is shown below the chart.
For my actual tests I attempted no conversion from the Arduino’s port A0 and A1 values, primarily because the data was non-linear and I could find no obvious formula for computing it. The Arduino port values, however, serve my purpose because I will be able to easily see a deviant LDR when compared to known good LDR. The image below shows the exact same LDR as tested above except this time plotted in Arduino port A0 and A1 values. The green “control” line in the image is the control plot of the known good sample. If the two lines are reasonably close, then the LDR is good.
Finally, the software is available at these clickable links: the Arduino script, named “ldrtest.ino” and the Linux shell script named “ldrtest.sh” and its accompanying gnuplot script named “plotscript.gp” and a file of control values, “control.txt“