Voltage divider and floating voltage read

Hi, I am new to arduino. This is my attemp to wire voltage divider and to use analogRead for measuring resistances with Arduino Uno

What I did is that wired 2 resistors (R1 and R2) in series on a breadboard. R1 is 100 ohm, and R2 is 100 ohm. Connected an Arduino uno to both end of this circuits 5v and GND. Added a 100nf ceramic cap from 5v to A1. Then uploaded my code.

The issue here is when insert R1 and R2 on the breadboard, the reading at analogRead drops from 1023 to around 850 ~ 950 (floating). I expect R1 and R2 should be around 1kohm to 50 ohm for measuring smaller resistors.

  1. Is there a method to predict how much analog reading will drop relates to the resistance in circuit?
  2. Is the uncertain drop rate relates to resistancy and current?
  3. Is the readVcc approach in this topic How to know VCC voltage in arduino ? can be adapted in this regard? I think it is about stable voltage. Just ignore this if not the case.

I cant find any resolution on this thread.
Thank you for your advise and reply
Ks..

#include <Arduino.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(A3, A4, 4, 5, 6, 7); 

float read; 

void setup() {
  Serial.begin(9600);
  lcd.begin(16,2);
} 

void loop() {
  read = analogRead(A1); 
  Serial.print("The A1 is ");
  Serial.print(read);
  delay(1000);
}

[Image]

[/image]

Hi @kamuss welcome to the forum.

You might want to look at this How to get the best out of this forum before you proceed any further.
We only know what you tell us, and without knowing what you have, we don't stand a chance.

For example word salad like this does not cut it in electronics:-

This sounds wrong, we need to see a schematic, Hand drawn is fine Fritzing is not.

I think you have totally the wrong idea about how to measure resistance, if you want to use it like a multimeter would measure it.

2 Likes

Your image shows A1 directly connected to 5V. Your Arduino should read (close to) 1023.
If you move the green wire from row 12 to row 16 (the connection of the two resistors), your Arduino will read around 512

Where is that capacitor that you mentioned?

Note:
analogRead() does not return a floating point number but an integer.

2 Likes

Hi @Grumpy_Mike @sterretje, thank you for your reply. I will test analog integer tonight. This is a complete picture.
[Image]


[/image]

That should not happen.
Check your wiring for loose connections, sometimes the skinny resistor wires do not make good contact in a breadboard.
Check your resistor values, make sure they are 100 ohms

1 Like

Yes, as I said this is not the way to measure resistance in a way that a resistance meter works.

Why have you got two resistors in series? Is the idea that you use one resistor as a fixed resistor, and the second resistor is the one you are trying to measure?

If so the top 100Ω is way too low. I would make that 10K, as the analogue inputs work best with a 10K impedance.

What is the range of resistors you are trying to measure?

1 Like

I rewired them in a clear and easy to observed position. The issue is not much different from before that the reading at analogRead at the red wire is floating around 1005 ~ 1020 before R2 is inserted, but not 1023. However, it is at the rate 880 ~ 999 after the R2 is plugged-in.
@sterretje
When A1 pin is connected at the point between R1 and R2 (the middle), the analogRead is floating between 480 ~ 500.
I tried to use int instead of float, it is a matter of adding two decimal after the analogRead number.
Here is the code

int read;

@Jishnuvn m-p, I realize that rickety resistors may often loose contact or make unstable connection in the breadboard. But not always. It may sometime be in a steady state to serve a stable connection if we are careful. Moreover, I am sure the value of resistors are 100 ohm both. I have rechecked them serveral times.

@Grumpy_Mike
"Yes, as I said this is not the way to measure resistance .." What would be your suggestions?
"Why have you got two resistors in series?" I suppose to determine the R2 from a known R1 as a fix resistance. That way, if the supply voltage is steady, I can measure the unknown resistor. The range of the unknown resistances would be from 2 ~ 1k ohm. For above 1k resistors, they should be my next goal.
My prime concern is that the "voltage drop" in the moment of measuring processes.

Rgds,
Ks..

As you are using a UNO the default reference is Vcc.
So the result from the ADC should be 1023 for Vin = Vcc.
Even if Vcc is pulled down by a heavy load the ADC reading should still be 1023.
The only way you would see what you are describing is if the connection from the 5V pin (red wires) to the top resistor & ADC had a resistance comparable to R1+R2.

I'm uncertain how you expect to do that. Perhaps you could post a schematic?

1 Like

That might very well be your reading.

You might be using the term floating incorrectly. Floating means "an input without any connection to ground". It does not mean constantly changing, although it can present like that.

To measure resistance you have to inject a small voltage into an external system and see what comes back.

Is this a class assignment in some way?

1 Like

Diagram schema capacitor to GND
[Image]


[/Image]

Display result (903 ~ 904)
[Image]


[/Image]

Circuit breadboard capacitor to 5v
[Image]


[/Image]

Those resistors look like 10R to me.

That is only a voltage divider if you use the point where the resistors meet. Otherwise it is just two resistors in series.

As that capacitor is connected to the +5v power supply it is not doing anything much for you appart from general supply decoupling. As you are connecting A1 to the 5V power supply then I can't see how that will make it measure anything except the 5V power supply. That should give a reading of 1024 from A1. If that is not what you are getting then you are not supplying a full schematic of your wiring, or you have some sort of bad connection in your wiring. Solderless bread board is notorious for connections that look fine but are not.

Basically you are not doing much to actually measure anything.

And if they are then putting 20Ω across the Arduino power supply is going to draw way too much current from the USB port and the voltage of the whole Arduino will drop.

I ask again:-

1 Like

Dislike those blue resistors, hard to tell black from brown, red from orange on a picture.

@johnerrington

default means I don't need to set anything. And it will set once I call analogRead, right? And the result from my analogRead is not 1023. What should I do? How to achieve ADC reading 1023 albeit having a heavy load? And what is ADC resistance comparable to R1 + R2?.
I chose R1 and R2 100ohm both this is a random pick. No idea what is the ideal.

@Grumpy_Mike

Ok a good term to avoid confusion. I would use "fluctuation, swing, or variation"

like setting analogReference()?

No, I am not an Engineering student, but I will take EE major.

@jCA34F, these resistors are 100 ohm.

It seems you are trying to follow something like this:

All you need is a simple voltage divider circuit such as this - I've drawn a nano and used A2 but of course you can use a uno and A0
image

With a resistor R1 of 1k you can measure resistances (r2) between 100k and 10 ohms
The cap just provides a bit of noise reduction - not absolutely necessary.

However this isnt a great way to measure resistance especially if you have no idea of the value you are trying to measure.

2 Likes

@johnerrington the unknown resistors to measure is in between 2 ohm to 1k ohm as in my post #7 above. The reference looks good suit to my need.

Get rid of all the bridge wires...
Put your resistor in 5V rail and some hole in the middle. Put the other resistor in gnd rail and the same row of holes as the first resistor.
That saves you a lot if potentially loose contacts...

1 Like

Seems like 100...
Brown black black black space brown
1 0 0 x 10^0 1% accuracy

1 Like

So, you win the GOLD in the eyesight Olympics! :grin:

1 Like

Definitely not. The last band cannot be black...
I have corrected my post...