Calculating resistance with Arduino

I’m trying to measure resistance with arduino Nano ATMega328, it works on paper, but Arduino doesn’t somehow calculate the resistance. LCD output: Voltage: 1.73 R1: -24495

Schematic and princible is here (first circuit picture):

R3 is in series with R1 to lower 12.08 voltage for arduino, so:
R1 = (R2*Vin)/Vout) - R2 - R3



What do you think R2 should be? Does that value actually fit in an int?

Hi, can you please use code /code tags to post your code. The link you give is nothing like what you describe. Can you post a CAD or pic of a hand drawn circuit diagram and if possible a pic of the project. Hint, float all the values you are using in the sketch. Hope to help.

Tom...... :)

Yes, the 17,76 kohm is calculated with Vin 12.08 V and gives 4.3 V Vout when R1 is 500 ohm.


Your equation for calculating R1 is wrong. Wikipedia gives a formula for two resistors: Vout = Z2/(Z2+Z1) - Vin

You have two resistors on the Z1 side, so Z1 = R1 + R3 and Z2 = R2.

Plugging that in gives: Vout = R2/(R2 + R1 + R3) - Vin.

Vout + Vin = R2/(R2 + R1 + R3)

R2 + R1 + R3 = R2/(Vout + Vin);

R1 = R2/(Vout + Vin) - R2 - R3 which is NOT the equation you have.

Wikipedia gives a formula for two resistors:
Vout = Z2/(Z2+Z1) - Vin

Vout = Z2/(Z2+Z1) x Vin

Their artwork sucks.

Tried this as a part of the code, but it gives still incorrect ansver R1 : -26129

R1 = (R2)/(Vout + Vin) - R2 - R3;

Paul's equation is wrong since he misread the equation in Wikipedia.

Tbird, your equation in your pic correctly solves for R1.

Thanks, I thought so because I solved it on paper. Thanks for all! Now back to calibration plans.