Pages: [1] 2 3 4   Go Down
Author Topic: Arduino reading different voltages than a multimeter  (Read 3128 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!
I know that LEDs can produce a voltage when light shines on them. First, I connected the cathode (short pin) of my LED to the black lead of the multimeter, and the anode (long pin) to the red lead of the multimeter. I shined a flashlight on a green LED, and the voltage was >0.2V on the multimeter. Next, I connected my LED's cathode to Arduino's GND and anode to analog input A0. I used the default voltage reference, and did this operation on the analogRead() of the pin.
Code:
voltage = rawADC * 5.0 / 1024.0;
I shined the same flashlight on the LED and the voltage was >1.5V! I tested it on my multimeter again. Why does the Arduino read the voltage as about 1.5V when the multimeter reads it as about 0.2V?
Thanks!
Logged


Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps they have different input impedance.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A depending on how directly you shine the light the multimeter definetly has too low impedance, unless you have a good one
Take a peak with an oscilloscope, (1M impedance usually) and add large value resistors in parallel and watch the responses, its pretty cool
the best thing you can do is use an opamp so the measuring impedance doesn't affect it
also use a blue led or white and you'll get 3v full brightness,
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is "input impendance"? Perhaps the LED's cathode potential is at +1.3 and the anode potential is at +1.5? The Arduino GND brings the cathode potential to 0, so the analogRead() result is 1.5V? I don't have an oscilloscope. I don't know how to use op-amps, and which op-amp to use.
Logged


Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Input impedance:
Your multimeter looks like a 100k or 1M resistor to the LED.
The Amalog Input looks like a 10k. correction from mike below.)


Also, you're using such a few number of bits on the a/d you'll have quantization error.  You might try using the INTERNAL analogReference() which is 1.1V instead of 5.
« Last Edit: June 21, 2012, 07:50:21 pm by James C4S » Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Before posting, I also tried the 3.3V reference. The results were the same. But how come the Arduino can measure the voltage of an AA battery properly?
Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Amalog Input looks like a 10k.
No you are mixing up the idealise source impedance with the actual input impedance. An arduino is likely to be in the range of 1M or so.

Quote
But how come the Arduino can measure the voltage of an AA battery properly?
Because the battery has a very low output impedance. That is it can supply far more current than an LED given the same voltage.
It is rather like the difference between temprature and heat. A spark has a very high temprature but there is very little heat in it. So one can land on your hand with little damage. A cup of boiling water is about 100 times cooler than a spark but has much more heat ( specific heat ) so it burns you far more seriously.
Logged

Offline Offline
Edison Member
*
Karma: 23
Posts: 1173
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know anything about using LEDs as light sensors...   I would guess it's unreliable or it would be done more often...

The simplest way to eliminate the impedance issue is to hook-up the multimeter and the Arduino at the same time.

If the LED is acting like a high-impedance voltage source (like I said, I don't know), you could be picking-up noise.   (The noise should be about the same with the light shining on it or not.)

It's likely that the multimeter has some filtering to smooth-out noisy readings.    So with a noisy signal, the meter reading could be lower and more stable even if they are both reading the exact same voltage at the exact same time.  (If you had an oscilloscope you could see if there is noise.)

« Last Edit: June 21, 2012, 07:14:19 pm by DVDdoug » Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2813
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

and note if the Arduino's response changes, should you measure a different voltage with the Arduino connected you will have your answer...

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unless you are shining a light directly into it very brightly the led will only put out 4mv with ambient light
kinda cool you can see the switching frequency of flourescent bulbs with an led detecting ambient light and an oscilloscope
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote from: winner10920
kinda cool you can see the switching frequency of flourescent bulbs with an led detecting ambient light and an oscilloscope
I'm not sure if the LED responds fast enough. Another way to to measure light with an LED is to hook it up backwards (anode to GND, cathode to digital pin). First, the digital pin turns into output and HIGH. That will charge up the LED's "parasitic capacitor". Then, the pin switches to input, and the Arduino times how long the "parasitic capacitor" takes to discharge. In complete darkness, it can be more than a second, but in direct bright light, it takes only about 0.02 seconds. I got that from http://provideyourown.com/2011/cheap-alternative-for-hard-to-find-cds-light-sensor/. This is the code:
Code:
class AmbientLightSensor {
public:
  AmbientLightSensor(int ledPin) : mLedPin(ledPin), mMeasureAnalog(false) {}
 
  void setAnalogMeasurement(int thresholdLevel); // measure from an analog pin
  void setDigitalMeasurement(); // measure from a digital pin (default)
 
  int measure();

protected:
  int mLedPin;
  bool mMeasureAnalog;
  int mAnalogThresholdLevel; // (0 to 1023)
 
  void charge();
  void discharge();
 
  int measureUsingAnalogPin();
  int measureUsingDigitalPin();
};
 
void AmbientLightSensor::setAnalogMeasurement(int thresholdLevel)
{
  mAnalogThresholdLevel = thresholdLevel;
  mMeasureAnalog = true;
}
 
void AmbientLightSensor::setDigitalMeasurement()
{
  mMeasureAnalog = false;
}
 
void AmbientLightSensor::charge() {
  // Apply reverse voltage, charge up the pin and led capacitance
  pinMode(mLedPin, OUTPUT);
  digitalWrite(mLedPin, HIGH);
}
 
void AmbientLightSensor::discharge() {
  // Isolate the diode
  pinMode(mLedPin, INPUT);
  digitalWrite(mLedPin, LOW); // turn off internal pull-up resistor, see http://arduino.cc/en/Tutorial/DigitalPins
}
 
int AmbientLightSensor::measure() {
  charge();
  delay(1); // charge it up
  discharge();
  return (mMeasureAnalog)? measureUsingAnalogPin() : measureUsingDigitalPin();
}
 
int AmbientLightSensor::measureUsingDigitalPin() {
  long startTime = millis();
  // Time how long it takes the diode to bleed back down to a logic zero
  while ((millis() - startTime) < 2000) { // max time we allow is 2000 ms
    if ( digitalRead(mLedPin)==0) break;
  }
  return millis() - startTime;
}
 
int AmbientLightSensor::measureUsingAnalogPin() {
  long startTime = millis();
  // Time how long it takes the diode to bleed back down to a logic zero
  while ((millis() - startTime) < 2000) { // max time we allow is 2000 ms
    if ( analogRead(mLedPin) < mAnalogThresholdLevel) break;
  }
  return millis() - startTime;
}
AmbientLightSensor led(12); // LED is hooked up to digital pin 12
 
int led2 = 9; // led to indicate darkness is hooked up to digital pin 9
 
void setup()
{
  Serial.begin(9600);
  pinMode(led2, OUTPUT);
}

void loop()
{
  analogWrite(led2, map(constrain(led.measure(),0, 400), 0, 400, 0, 255));
  Serial.println(led.measure());
}
This way is more sensitive, but slow responding

Quote from: Docedison
and note if the Arduino's response changes, should you measure a different voltage with the Arduino connected you will have your answer...
What?
Logged


Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2813
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah it is also an issue as the Fluorescent Lights actually turn off and on 60 times a second and this has to be filtered for some light detection schemes. My employer was an engineer, he came to me one day and explained that a photo detector he made "Hummed" but only at night and when I got through chuckling I told him to put a 100 uf cap on the output of the detector switch and add a diode and resistor to discharge the cap.... I made a color detector 25 years ago that fit in a hollow cane (aluminum tubing) for the blind... It would work nicely at night to detect which traffic light was on, Red, Yellow or Green. I used the 60 hz signal on the led's output to detect the traffic light but it was easily "Falsed" by Neon signs. LED's are much higher in intensity and sensitivity is much better now. I have a night light that uses 170uA and works well on a 2032 Lithium coin cell so I don't kill myself going to the WC at night. But with 35 - 40 mA driving it it makes a great blue flashlight... too bright for me to sleep. 20 Candela's advertised (20,000 milli candelas) and about $0.10 each. An LMC6022 and a couple of resistors makes a nice, Very low current photo-detector that will swing rail to rail from a 9V battery. Great @ 5V too I used them a lot.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I know the led responds fast enoughbecause I've seen it, lol not only the 60hz but the multiple Khz switching frequency, which we would never see fluctuating with our eyes but the led can see
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 462
I am a amateur.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I know the led responds fast enoughbecause I've seen it, lol not only the 60hz but the multiple Khz switching frequency, which we would never see fluctuating with our eyes but the led can see
I meant detecting light, not lighting up.
Logged


Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well yeah, I mean with just an led hooked up to an oscope, you can see the switching frequency of the flourescent, from that led detecting it
Logged

Pages: [1] 2 3 4   Go Up
Jump to: