0

I'm trying to detect light using an led that's already attached to the circuit. I have a flashlight shining on the led.

Minimal sketch:

while( true )
{
    int photoValue = 0;
    analogReference(INTERNAL);
    photoValue = analogRead(A5);

    Serial.println(photoValue);

    delay(300);

}

While I have my multimeter attached, it reads a pretty constant value around 5mV. The serial output however swings around, as seen in this sample output:

0
0
4
4
0
16
15
22
21
25
20
36
40
34
36
24
5
0
3
6
0
0
0
0

That would translate to values between 0 and 43mV.

When I disconnect the multimeter only get 1023 printed.

I don't get how the values from the ADC and the multimeter, totally don't match.

11
  • 1
    Can you show your circuit?
    – Majenko
    Commented Aug 2, 2016 at 19:01
  • 1
    I strongly suspect that the LED isn't able to produce enough current to charge the S&H capacitor. Plus the LED, when not generating enough voltage, will most likely make it look like the pin is floating somewhat. You may need a high impedance buffer between the LED and the ADC.
    – Majenko
    Commented Aug 2, 2016 at 19:15
  • In a few days I will have high impedance buffers available on eBay based around the OPA355. I will experiment with one when the components arrive to see what a difference it makes.
    – Majenko
    Commented Aug 2, 2016 at 19:38
  • Not enough current; makes sense. The circuit is 8 LEDs in parallel, connected between gnd and A5. Tomorrow I'll try adding a small capacitor to the A5 pin. I don't have any room for something like an opamp. So if that doesn't work I'll just have to scrap this, nice to have, extra feature.
    – Gerben
    Commented Aug 2, 2016 at 20:09
  • 1
    That is awesome! I love it! I expect to see it on the catwalks of London, Madrid and New York soon!
    – Majenko
    Commented Aug 3, 2016 at 10:19

1 Answer 1

1

The problem you are facing is that the output of the LED is too high impedance for the ADC to work reliably.

Basically the LEDs can't produce enough current to charge the S&H capacitor properly, and on top of that the LED doesn't act as a resistive load when not forward biased, so the input is basically floating and picking up noise.

The best cure is to add a voltage-follower buffer with incredibly high input impedance in front of the ADC input.

By high impedance I mean something measured in the 10s to 100s of TΩ. Something like the OPA355.

1
  • Thanks for all the feedback. Due to the deadline I have to scrap the idea for now. But the next competition is in October, so maybe then. Anyway; much appreciated.
    – Gerben
    Commented Aug 4, 2016 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.