[Analog input] Literally random values from a photodiode

I'm using this photodiode (the 5k one) (248KB) http://www.hamamatsu.com/resources/pdf/ssd/s2386_series_kspd1035e.pdf I've put it in parallel with a 4Mohm resistor, and this is what I read with analogRead (Arduino UNO r3).

0
261
1023
1023
0
3
541
1023
0
121
433
1023
0
0
73
1023
994
0
274
1023
968
0
21
656
1023
0
137
435
1023
0
0
250
1023
235
1
0
914
1023
0
141
660
1023
0
151
488
1023
0
28
71
1023
245
7
158
1023
405
0
74
1023
1023
0
0
595
1023
0
49
186
1023
0
0
206
1023
1023
0
242
1023
530
0
287
1023
723
0
15
1023
994

Completely random values. They even change with constant light... I already tried changing the analog input pin. I tested them with a photoresistor and they work properly. I tested the photodiode with an oscilloscope with the same resistor value and it works right.

Don't know what to do anymore, here's the code I use:

unsigned long const baudrate = 9600;
int const phr = A1;

void setup()
{
  Serial.begin(baudrate,SERIAL_8N1);
}

void loop()
{
      Serial.println( analogRead( phr ) );
}

Here's the circuit http://i.imgur.com/os44fe3.jpg

(trust me that the photodiode is properly connected)

What light were you using to be measured? ( The light source I mean ) Dwight

I don't see you connect a ground wire.

+1
Ground is missing.

Arduino’s A/D converter likes to see an input impedance of <=10k.
4megohm is 400x the limit, and could give false readings.
A 4meg impedance picks up hash easilly, and therefore needs shielded wiring.

Unless you have a 100n cap across (? blue part ?)

What is your application.

Static low light, modulated light…

Mains lighting is modulated with the mains frequency…
Leo…

Solid state florescent will also produce cyclic noise but at something other than 60Hz. The readings are clearly cyclic. If that were the sun, I'd be more worried. Dwight

dwightthinker: What light were you using to be measured? ( The light source I mean ) Dwight

Phone flash or I covered it with my hand

The light source is obviously pulsed. You are seeing the pulses. Your sampling rate is beating, in frequency, with the pulse rate of the source. As was mentioned, you could slow the response of your interrupter with an input filter. Dwight