DIY Science: Measuring Light with a Photodiode II

In an earlier post I described several very basic photodiode circuits. I also stated that I would post an entry on how to breadboard those circuits and how to implement them with an Arduino microcontroller. Well, here it is.

Figure 1. Breadboarded version of the photodiode-resistor circuit.

Figure 1 and Figure 2 are Fritzing diagrams of the resistor and amplifier circuits that I diagrammed in the earlier post. (Click either figure for a larger view.) Both circuit configurations require an Arduino Uno, the Arduino IDE software package, a solderless breadboard, jumper wire for making connections, a USB cable (A-to-B plug), and a PDB-C139 photodiode by Advanced Photonics, Inc., which I purchased from Digi-Key (link). The resistor circuit also requires a 470 ohm resistor. The amplifier circuit additionally requires a garden variety 10 kilo-ohm resistor, a 100 nanofarad ceramic (non-polarized) capacitor, and an operational amplifier with a small input offset voltage. In this instance, I purchased an LTC1050 chopper-stabilized op amp by Linear Technology Corporation (DigiKey link here). I won’t say anything here about how chopper-stabilized operational amplifiers work. I’ll simply say that their accuracy and stability surpass those of less expensive op amps like the ubiquitous 741-type amplifier.

Figure 2. Breadboarded version of the photodiode-amplifier circuit.

If you have the appropriate hardware, then you should be able to breadboard the circuits and view the Arduino’s output using the Arduino software’s serial monitor. You can write your own Arduino code, or you can modify the simple code presented at the end of this post.

As you breadboard, keep in mind that the photodiode’s positive (+) lead, or anode, is longer than its negative (-) lead, or cathode. For the circuits to work correctly, you’ll have to orient the photodiodes so that they have the correct polarities. One last point before I move on to the results of my initial test — if you look carefully you will notice that there is a slight difference between the amplifier circuit that I breadboarded in Figure 2 and the one that I diagrammed in that earlier post. I have added a capacitor to the circuit in Figure 2 that wasn’t present in the original circuit diagram. Without this capacitor, the circuit’s output voltage oscillates pretty rapidly, yet slightly, about its mean. The capacitor eliminates those oscillations. However, it doesn’t appear to reduce the circuit’s sensitivity to real changes in light intensity.

Figure 3. Output voltages from the amplifier (solid) and resistor (dot) circuits on a partly cloudy day.

I performed a 6 minute test of each circuit just to see how things worked. I measured the signal produced by incident sunlight on a partly cloudy day, and I recorded it at 10 Hertz. The results are shown in Figure 3. The first thing that you’ll probably notice is that the amplifier circuit’s signal is much stronger than the resistor circuit’s signal. That is by plan. The maximum possible voltage ouput by the resistor circuit is fixed by the light response characteristics of the photodiode. However, the voltage output by the amplifier circuit is variable: it is determined largely by the value of the feedback resistor that is used in the circuit. The op amp permits me to amplify the photodiode’s output as much as I like. The Arduino can read a maximum input voltage of 5V — higher voltages are read as 5V regardless of their true values. To accommodate that limitation, I plugged different resistors into the amplifier circuit until I found one (10k\Omega) that produced a circuit reading of around 4.8V in full, direct sunlight.

The second thing that you’ll probably notice about Figure 3 is that the amplifier circuit is very sensitive to the presence of clouds. Obviously, the highest values were recorded when sunlight passed through breaks in the cloud cover, and the lowest were recorded when the sun was obscured by the thickest clouds. What I found to be remarkable, however, was that even the wispiest of clouds produced readings as they passed in front of the sun, even though their effects were imperceptible, or nearly imperceptible, to the eye.

More test results later … but for now, you can play around with the circuit and sample code —

/* Here is a bare-bones Arduino sketch to read the
   outputs of the photodiode detectors described
   in Figure 1 and Figure 2. The output pin of the
   circuit's opamp is connected to analog pin 0
   of the Arduino. The data are read every 0.1 second
   in this example. However, you can change the sampling
   rate by simply changing the argument of the
   delay() statement. */

#define inPin0 0

void setup(void) {


void loop(void) {
  int pinRead0 = analogRead(inPin0);
  float pVolt0 = pinRead0 / 1024.0 * 5.0;

About Dr. Taiga

Arborist/landscaper by day ... amateur scientist by night!
This entry was posted in DIY Science, Electronics, Sensors. Bookmark the permalink.

1 Response to DIY Science: Measuring Light with a Photodiode II

  1. PDamateur says:

    This is very useful for a personal project. Is there a link to your GitHub that you could provide?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s