Problem reading inputs with Analog 0, Arduino nano.

Hello,

I built the circuit in the picture below

The purpose of this circuit is to measure light intensity.

and uploaded the code below to my Arduino nano

 /* 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) {
 
  Serial.begin(9600);
  Serial.println();
     
}
 
void loop(void) {
   
  int pinRead0 = analogRead(inPin0);
  float pVolt0 = pinRead0 / 1024.0 * 5.0;
  Serial.print(pVolt0);
  Serial.println();
   
  delay(1000);
   
}

The reading that I'm getting is always 0.00 I don't know why, can anyone help ?

If you wired it exactly as shown in that Fritzing diagram (one can never tell with those awful diagrams), then it should work. But make sure the photodiode is the right way around and reverse it if need be.

The standard schematic below shows a much clearer representation of the circuit, with the diode in "photovoltaic" mode.

Current flows from the photodiode through the resistor and back, in a circuit.

pd.png

pd.png

Still getting 0.00 as the reading. I tried different values for the the resistor but it didn't work.

I tried to remove the resistor then it worked, why didn't it work with the resistor?

What photodiode and what value resistor did you use?

1 Megohm resistor would be appropriate for low light levels.

I used this photodiode PDB-C139 Advanced Photonix | Sensors, Transducers | DigiKey

I used 100 ohms for the resistor and tried 10K

And what light level?

If you are serious about measuring light intensity, that circuit is not the way to do it. You would use a reverse biased photodiode and usually, a transimpedance amplifier.

Search the forum for many discussions and examples.

I'm trying to measure the light coming out of a regular home light(LED)

No I'm not very serious about it I just want to try it out and learn some new stuff.

Ultimately this is what I'm trying to do DIY Science: Measuring Light with a Photodiode II | Outside Science

I tried both circuits and both of them give me 0.00

Photodiodes are most sensitive to infrared. You don't expect much output when exposed to an LED home light, which produces no infrared.

This sketch is about 5x more sensitive, and should work (tested with a common LED as sensor, and a LED torch).
If.. the burden resistor is ~100k-1Megohm and the polarity of the photo diode is right (cathode to ground).
The 5mm green LED I found on the floor, and a 1Megohm burden resistor even detected daylight inside.
A 100n cap across the LED was needed to stabilise the readings.
Leo..

void setup() {
  Serial.begin(9600);
  analogReference(INTERNAL);
}

void loop() {
  Serial.println(analogRead(A0));
  delay(200);
}

The circuit in #1 is wrong, no wonder you read 0.00 all the time because you effectively connect your analog pin to the ground. You should wire it as voltage divider instead, like this image (just Googled "how to wire a photo diode"):

Photo diodes are indeed very sensitive to IR and therefore commonly used for receiving IR signals, like from a remote control or as alarm.

Even easier: get a digital lux sensor like the TSL2561, and you get an absolute number in lux right away. It also has an IR filter built in.

wvmarle:
The circuit in #1 is wrong..

No, it's not.
That diagram shows a photo diode used in photovoltaic mode (like a solar cell).
Leo..

Wawa:
This sketch is about 5x more sensitive

What sketch?

What sketch?

See reply #8

The circuit works just fine if I only connect the photodiode

wvmarle:
The circuit in #1 is wrong, no wonder you read 0.00 all the time because you effectively connect your analog pin to the ground. You should wire it as voltage divider instead, like this image (just Googled "how to wire a photo diode"):

Photo diodes are indeed very sensitive to IR and therefore commonly used for receiving IR signals, like from a remote control or as alarm.

Even easier: get a digital lux sensor like the TSL2561, and you get an absolute number in lux right away. It also has an IR filter built in.

I tried to wire it as a voltage divider. It kept giving me a reading of 5.00

I tried to wire it as a voltage divider. It kept giving me a reading of 5.00

No surprise, that is a bad circuit.

Hi,
You are trying to use the photodiode as a voltage output device.

A photodiode is like a PV a CURRENT SOURCE.

The current is very very small, uA, you need to, as previously advised, amplify it.
In particular a Trans-conductance Amplifier to convert current to a voltage output.

Tom... :slight_smile:

With the sketch from post#8 and a common green 5mm LED (with 1Megohm resistor and 100n cap across) I got stable readings of around 50 with dim daylight (rainy day).
I assume a real photo sensor (with larger chip area) will do much better than that.
Will dig one up tomorrow (midnight here).
Leo..

edit:
With a BPW34 with 100k burdon and 100n cap across I get values of ~300 inside.

I rearranged the circuit according to what people suggested with the current resistors that I have but no luck. I'm only getting reasonable readings when I only connect the photodiode. I'll get a 100k - 1M resistor to try if it works.

Not a problem to use the photodiode without resistor across, as long as you're getting values below ~300.
A burden resistor just makes the sensor less sensitive.
Low(er) values are needed when you measure e.g. daylight or sunlight.

The 100n cap across is needed when the burden resistor is >10k (or missing),
to keep hum pickup of the wiring under control and to give the A/D someting "solid" to sample from.
Leo..