Broken Analog In?

It seems there is something wrong with my analog input pins and I was hoping to understand why / how to fix them.
I have an Arduino Duemilanove and am connecting two resistors (same rating) in series between 5V and GND. I am measuring the voltage in between the two resistors (should be 2.5V) and am getting weird values.

When I take a reading at the middle point (I expect something like 2.5V / 5V * 1023 ~= 511), but I actually get 648... The weird thing is this: when I test the circuit with a multimeter it all looks fine. (5V at Vdd, 2.5V in the middle and 0V at GND), but AS SOON AS I CONNECT A0 in between the resistors, it changes its voltage (to 3.2V which is it's reading 648). Why would connecting the analog input pins of the arduino alter the circuit?

This happens on all analog input pins. And the effect is exacerbated if I use higher rating resistors (less current??)

Couple of things I've checked already:

  • pinMode is set to input
  • AREF is 5V (manually set using analogReference(DEFAULT) and confirmed with multimeter)

Bonus weird:
A0 gives a reading of 648
A1 gives a reading of 722
A2 gives a reading of 780
A3 gives a reading of 770
A4 gives a reading of 941
A5 gives a reading of 840
(exactly the same setup, just moving the input jumper from one analog pin to the next)

I understand this points to something dodgy going on with my Arduino (although would be super happy if someone pointed out otherwise), but at the same time it's not like something catastrophic has gone wrong... (doesn't seem like any shorts or anything). Could someone who knows about this stuff give me a hand?

What value R are you using?

Try with value of 10k each resistor.


And put a capacitor between the analog pin and ground (.01 - .1 uf).

Read it with a voltmeter.

If your resistors are not 1%, then you can expect some variance also.

Show us your script.

Sorry, yes should have mentioned. Those values were using 1K resistors.

10K resistors exacerbates the behavior. I get the following:

A0: 977 (from 999 floating)
A1: 985 (from 999 floating)
A2: 987 (from 997 floating)
A3: 655 (from 657 floating)
A4: 963 (from 967 floating)
A5: 1001 (from 1009 floating)

It appears connecting the input pulls it slightly closer to the actual value...

From the analogIn pin sitting at ~4.8V unconnected -> As soon as I connect it, instead of actually changing and matching the 2.5V sitting in the circuit, it is instead pulling the circuit value up to almost 4.8V (ie somewhere in between the 4.8V and 2.5V... but much closer to the 4.8V)

EDIT: Adding a capacitor between A0 and ground (0.1uF), I still get 977 (as above for A0).
Voltmeter says 4.72V which matches the 977 (but as soon as I disconnect the A0 from the circuit, the same point reads 2.46V)

Thanks for your reply.

Script attached. Apologies, haven’t stripped it down. Began as example code for ML8511 UV Sensor.

UVSensor.ino (3.26 KB)

Sorry, but I am using chromebook, and it can't display a downloaded *.ino file.

Maybe you can put the pertinent part on the forum with code tags, or
Maybe someone else can view the .ino file.

Have you used the analog read pins before (with success)?

Sure. Stripped code as follows:

Analog Pins have worked for me in the past.

int UVOUT = A1; //Output from the sensor
int REF_3V3 = A0; //3.3V power on the Arduino board

int LED_CHECK = 13;

void setup()
  pinMode(UVOUT, INPUT);
  pinMode(REF_3V3, INPUT);

  Serial.println("ML8511 example");

void loop()
  int uvLevel = averageAnalogRead(UVOUT);
  int refLevel = averageAnalogRead(REF_3V3);
  digitalWrite(LED_CHECK, (uvLevel > 700 ? HIGH : LOW));

  Serial.print("refLevel: ");
  Serial.print(" | ");

  Serial.print("ML8511 level: ");

//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
  byte numberOfReadings = 8;
  unsigned int runningValue = 0; 

  for(int x = 0 ; x < numberOfReadings ; x++)
    runningValue += analogRead(pinToRead);
  runningValue /= numberOfReadings;


Anyone got any ideas? Should the input resistance / current affect the analog input readings? Is there a limit?

"Voltmeter says 4.72V which matches the 977 (but as soon as I disconnect the A0 from the circuit, the same point reads 2.46V)"

This seems to be the problem area. But why would it act that way?

Just for a test, maybe try adding the function

int spotAnalogRead(int pinToRead)
   unsigned int  analogValue  = analogRead(pinToRead);

And call it rather than calling averageAnalogRead().

That should give some delay, and limit number of analogRead calls.

I assume you are using two 10k resistors (voltage divider), and the 0.1uf cap.

You can easily switch the call back to the original function when done testing.