Problem implementing Op Amp for light measurement with photodiode

Dear all,

I’m building a DIY spectrophotometer using an Arduino UNO R3. I chose a photodiode for the light detection part because of its linear response to light intensity, which is not the case for photoresistors. As you may have guessed, my priority is accuracy rather than speed. The photodiode I’m using is the BPW34. I’ve already played around with it, and I found that I get a much stronger signal by applying a reverse bias utilizing Arduino 5V output. Now I want to go even further and enhance the detector sensitivity by using an Op Amp. I’ve been using the NE5532P to do so. I’m using this merely because I bought it a couple of years ago for a similar project, although I’m not sure if it’s appropriate for my current application. A schematic of the circuit I’m using follows attached. I know that the use of a capacitor is recommended, but it isn’t necessary and I don’t have access to one at this moment, but it will be implemented as soon as possible. The code I’m using is this:

#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(100);
   
}

So, here comes my problem: Under room light Arduino is reading voltages as high as 4.39 V. When I cover the photodiode with my hands it can reach 5 V. If I turn on a strong light source close to it, the voltage will decrease to 4.28 V. Why is the voltage so high? Why is the response to light so small? Why is the response to light intensity inverted?

Although I’ve read a lot about Op Amps, I suppose I’m not using mine properly. Or maybe the model I’m using is the problem… I don’t know.

Thank you in advance!

Best regards,

Gustavo

Fritzing diagrams are useless. Please post a hand drawn schematic instead, with pin numbers and parts clearly labeled.

Here is a great resource on photodiode amplifiers.

Dear jremington,

Thanks for your reply.

Please find attached the schematic. I hope this is what you’re asking for. I’ll also update my first post.

About the document, I’ve actually read it recently. It’s good indeed.

Best regards,

Gustavo

The schematic is much better, thanks.

If you have the photodiode installed as indicated by the schematic (and not the wrong way around) that circuit should work, if the op amp is chosen correctly. However, you MUST have a decoupling capacitor directly across the op amp power pins (100 nF). It is not optional.

The NE5532 is a very poor choice of op amp and is likely to be the problem. It is not intended for low voltage single supply operation and the inputs and output are not "rail to rail". The existing circuit could also be oscillating. Check with an oscilloscope.

You can make this circuit work with the NE5532 if you use a bipolar power supply like +/- 5V or +/- 9V.

Finally, the feedback resistor is too small. You might expect about 50 uA photodiode current under typical room lighting, so 100K would be a better choice.

For the low light levels in a spectrophotometer, special circuitry with extremely high input impedance op amps and careful, clean PC board design is absolutely required, with "guard rings" around op amp inputs. ~100 Meg feedback resistors are often used.

Dear jremington,

Thanks for your valuable comments.

About the capacitors, my 100 nF ones are on their way, but I'll have to wait a few weeks until they arrive. So, I have to put them next to the Vcc+ and Vcc- pins, right? What are these capacitors supposed to do in my system?

I don't have access to a bipolar power supply, but I read that it's possible do create one by using two good quality batteries. I already have a 9 V one, so I might buy an extra and try this out.

A more permanent and simple solution, however, seems to be changing the Op Amp. Which one(s) would you recommend for my case?

100 K resistor: noted. About resistors, do you think it's good to have one (let's say, 2.2 K) between the Op Amp output and A0 in order to prevent any damages to Arduino?

Regarding the last paragraph, I'll keep all this in mind. I just don't understand much about these guard rings, but I can come back to it later.

Best regards,

Gustavo

What are these capacitors supposed to do in my system?

Help prevent the op amp from oscillating, and remove high frequency noise from the power supply leads.

do you think it's good to have one (let's say, 2.2 K) between the Op Amp output and A0 in order to prevent any damages to Arduino?

Not needed, if the op amp output stays between 0 and 5 V. Otherwise, yes, 10K.

There are thousands of suitable op amps. Look for "rail to rail" on output, high impedance input that can be grounded, single supply. I've been using the Microchip MCP601-604 series, which runs on 3-5V.

Hi jremington,

Thanks for the information.

The MPC601 seems to be excellent. The MPC603 seems to be simpler, but I don't know how this Chip Select function can interfere in my project. The problem is that I can buy 50 LM358s for the price of one MPC, so I'm not sure if it's the best option right now. The voltage input range of the LM358 is wider and it's not rail-to-rail, but it looks like something that would work.

Thoughts?

Best regards,

Gustavo

For best results use a photodiode amplifier chip! Having said that a device with low current noise and
low bias current is the best choice, ie JFET or CMOS inputs and designed for low-noise. If you
want to measure a large range of light levels a way of switching different feedback resistors into
the circuit using analog switches may be useful.

The NE5532 is not low input bias current as its a bipolar opamp, won't be much use at low light levels.

The MCP601 costs $0.45 at Digikey, plus shipping.

Is that price entirely out of reach?

MarkT:
For best results use a photodiode amplifier chip! Having said that a device with low current noise and
low bias current is the best choice, ie JFET or CMOS inputs and designed for low-noise. If you
want to measure a large range of light levels a way of switching different feedback resistors into
the circuit using analog switches may be useful.

The NE5532 is not low input bias current as its a bipolar opamp, won't be much use at low light levels.

Thanks for your comment, Mark T.

I'll keep this in mind. For now I'll try the "difficult way" so I learn more about Op Amps.

jremington:
The MCP601 costs $0.45 at Digikey, plus shipping.

Is that price entirely out of reach?

Not really. The problem is that I'm living in Denmark and Digikey wants to charge me $22,00 for the shipping, even from the danish website. But nevermind, I've just found the component on AliExpress for an affordable price. I'll just have to wait some weeks.

I'll post it here when I get relevant updates about this little project.

Best regards,

Gustavo

There might be an "RS-components" in Denmark.
They do free shipping (at least where I live).
Leo..