Photodiode trouble

I am trying to read a photodiode with the arduino. Here is the spec sheet for the sensor: http://sales.hamamatsu.com/assets/pdf/parts_S/S1787_series.pdf

I have wired it exactly as directed in this page: Arduino Playground - PhotoResistor. I am taking the average of 4 values per 2 seconds to smooth any big fluctuations in light. Here is my code:

int lightPin = 5;  //define a pin for Photo resistor
const int reads = 4; 
float light[reads];  
float lightTot = 0; 
float lightAvg = 0; 
 
void setup()
{ 
  Serial.begin(9600);  //Begin serial communcation
   
  for (int i = 0; i < reads; i++){
   light[i] = 0; }
}

void loop()
{
lightTot = 0;
 for (int i = 0; i < reads; i++){
 light[i] = analogRead(lightPin); 
 Serial.println(light[i]);
 lightTot = lightTot + light[i]; 
 delay(500);
 }

lightAvg = lightTot / reads;
 
 Serial.println("Total");
 Serial.println(lightTot);
 Serial.println("Avg");
 Serial.println(lightAvg);
 Serial.println();

}

I have tried a range of resistors (100K, 10K, 2.2K, and 1K). However, I return either zeros, or inconsistent values that jump around (including zeros). Any suggestions or ideas would be appreciated. Thank you.
-Dave

A photo diode is not a photo resistor, not even slightly!

Two ways to use a photo diode:

  1. Place a large value resistor across it (100k to 10M range?) and measure the forward voltage. This mode is like a photo-voltaic cell

  2. Have it reverse biased and measure the photocurrent - this is the closest to the photoresistor circuit, but again the resistor may need to be a large value in low light. Some photodiodes are optimized for high-speed operation in this mode for communications.

UPDATED: Previous posting here was based off a wiring mistake. Please disregard if already viewed.

@MarkT: Yes I understand, I was just using that link as an example of the circuit rather than attempting to draw it out here. I have read multiple other posts which utilize that same circuit for a photodiode. Ill just assume they were incorrect. With your suggested reverse bias configuration, my average values are much more consistent (configuration like in Fig 2 here: http://goo.gl/7kL5H; Vcc = 5V, Rl = 100K).

If I want to change the sensitivity of the diode to higher or lower light, I would decrease or increase (respectively) the resistor value, correct? What if I need to measure a very broad range of light levels? Do I go with something in the middle?

My goal is to measure light levels throughout the day inside of a plant growth chamber which is shaded to approx 15% full sunlight.

Hey guys! I have the same question. I'm using a BPW21R photo-diode to measure the quantity of light in an optical fiber. I'm using the photo-diode with an Arduino Nano 3.0. I've tried to use the same scheme above but I got some wrong numbers. Does anyone can help me with that? I used resistors of 2K, 10K 100K and when I open the serial monitor the result is 0. When I take the resistor off the value showed is 1023.

I've tried to use the same scheme above but I got some wrong numbers

Did you not read the answer above?

A photo diode is not a photo resistor, not even slightly!

So there is no point in using a photo diode with the circuit of a photo transistor.

This sort of thing:-

Yes I understand, I was just using that link as an example of the circuit rather than attempting to draw it out here.

Really pisses people off. There is no point in posting an example circuit we need to see the EXACT circuit you are using.

I'm using the scheme from Arduino notebook page 37:

If that scheme isn't the correct way to get data from the photo-diode, does anyone know?

It would help if you actually used the symbol for a photo diode so we could see which way round you have it.
Basically a photo diode usually needs an amplifier.
I used one in this project:-
http://www.thebox.myzen.co.uk/Hardware/Sneak_Thief.html