analogRead - Getting odd values when reading the voltage

Hey folks!
Recently got into Arduino and electronics - so please bare with me if this is an odd question!

I am trying to read voltage across two resistors (330 Ohm and 110 Ohm) in my set-up. Whenever I do this I end up with some odd values for my readings.
I have been following a video tutorial on YouTube - and as far as I can see, everything has been done the same way.

In the diagram I am trying to read the voltage across the resistors using the green wire.
From what I have calculated, I should read around 3.75V across the 330 Ohm resistor and 1.25V across the 110 Ohm resistor.
Instead I get loads of different values such as:

  • 5V constantly across the first resistor
  • 4.45V constantly across the first resistor
  • 0.02 - 0.03V across the second resistor
  • Seemingly random values going up and down like crazy

The code I have is this:

int readPin = A3;
float v2;
int delayTime = 1000;
int readVal;

void setup() {
  // put your setup code here, to run once:
  pinMode(readPin, INPUT);

void loop() {
  // put your main code here, to run repeatedly:
  readVal = analogRead(readPin);
  v2 = (5./1023.) * readVal;

I have done a few things trying to figuring it out… These things are as follows:

  • Changing resistors to new one (multiple ones)
  • Changing the cable connecting the Arduino to the PC
  • Changing the wires
  • Tried on both my Arduiono M0 Pro and Arduino Uno
  • Using different analog pins

None of these things have seemed to help - hence I decided to try my luck here!

Hope somebody can help!
Schematic attached!

Why is A3 connected to GND ?
It should only be connected to the junction of the 2 resistors

Voltages are always measured with reference to ground.

So with the wire connected to the join between the two resistors you can only read one voltage and that's the voltage across the resistor connected to ground. It should be around 1.25V. To find the other voltage you have to calculate it as (5 - the first voltage).

With the wire in other position it is connected to GND so you should measure exactly 0V.

If you're not getting that then your circuit isn't what you think it is. Perhaps a photo clearly showing the wiring and components would show us something


Voltages are always measured with reference to ground.

Just adding to that - The Arduino reads voltages relative to it's ground. A multimeter doesn't have a "ground" lead... It has a "common" or "minus" lead so you can measure separately across each resistor.

And if you made a battery & voltage regulator circuit separate from the Arduino you could measure across either resistor depending on where you connect the analog & ground pins. But unlike a multimeter you can't read negative voltages so the Analog input always has to be positive relative to the Arduino's ground.

This is your experimental arrangement:


You can measure the voltage across the 110 ohm resistor to ground;
you CANT measure Vcc - because its too big;
nor the voltage across the 330 resistor -
because measurements are ground referenced.

With A3 connected to the junction of the resistors as shown you should measure ABOUT

5V * 110 / (330 +110) = 1.25V

I looked at your code; you havent declared a reference - so it will use the DEFAULT of the Vcc rail (which, as this is a divider, will be OK)

For accurate reliable measurements you should take a set of readings and average them.

Try Serial.println(readVal) to see what the data is, and post your result please.