Good luck to all code masters
I need a code that measures resistance from 0 OHM to 50 ohms. I couldn't find it despite searching on the internet. I tried many codes. None of them measure anything below 50 ohms properly.
Good luck. I'm waiting for your help.
Thank you.
We do not know what you tried and we do not know what the problems are that you have experienced.
Using below schematic you can read the voltage on A0. On a 10-bit ADC (e.g. AVR) 512 would indicate 50 Ohm, 0 would indicate 0 Ohm.
Don't forget to connect the GND with the microcontrollers GND.
R2 is the resistor to measure.
I tried this but unfortunately it reads 10 ohm as 13 or 14
Then multiply for a factor to get the correct value.
What was the resistance tolerance?
What was the voltage of Vcc?
Is Vcc able to supply at least 100mA of current?
Look, this might interest you : https://www.youtube.com/watch?v=cX1wUcqiyhQ
Note : It is important that the value of reference resistance is very precise;
Also, external phenomena, such as small temperature variations,
for example, can also influence its reference value.
The code from the author of the video above is very basic.
A more serious alternative would be to perform a logarithmic A/D ratio conversion,
there are integrated circuits dedicated to this use.
Short wiring required
What did you read on A0 when you got that answer?
And we are waiting for you to post your code.
And how did you calculate the resistance?
I've just done a test using an arduino Uno R3 and Sterretje's schematic from post #2, and got good results.
int inputPin = A1;
unsigned int raw = 0 ;
float resistance = 0 ;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup() {
Serial.begin(115200);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = previousMillis + interval;
raw = analogRead(inputPin);
Serial.print("ADC reading = ");
Serial.println(raw);
resistance = (50.0 * raw)/(1024.0 - raw);
Serial.print("Resistance = ");
Serial.print(resistance);
Serial.println("Ω");
Serial.println("");
}
}
The Arduino measures the resistance as 9.81Ω:
And here's what my multimeter said:
Can you give me your code so I can try it out, thanks
I've included it in post #10.
Click on that arrow above where it says 'Details': ![]()
I used analog input A1, you can edit the code to use A0 if you need to.
It's likely more a problem of the unseen circuit than the unseen code.
Does that mean you can properly measure from 50 to 100 ohms with one of the codes that you have tried?
If so, then add a 50 ohm resistor in series with your Device Under Test, do the measurement, then subtract 50.
Thank you to all the friends who helped me, I solved the problem thanks to you.
Do you mind sharing your solution?
I'm not sure you have.
Measuring small values of resistance with any accuracy is not simple.
If you use ohms law then you need either to apply a relatively large current, or measure a small voltage.
eg @sterretje 's circuit requires a supply capable of providing 100mA.
Applying a large current means the resistor will get hot - and change its value.
You will also see resistance and thermoelectric effects at junctions.
To accurately measure the small voltage across the test resistor you need a 4 terminal connection.
https://www.seaward.com/gb/support/resistance/faqs/80544-how-do-we-measure-low-resistance/
What degree of accuracy do you NEED over the range? and REALISTICALLY what range of resistance values? As you approach zero the issues become more complex.
eg 0.01 - 100 is 4 decades.
Great.
Have a nice day!
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1024.0);
float Rx = voltage / 0.104;
// print out the value you read:
Serial.print("Resistance:");
Serial.print(Rx);
Serial.println(" Ohms");
delay(1000);
}
I don't think that that takes into account that the behaviour or the circuit that I gave is non-linear. Try with different resistor values.
Next time, please post code using code tags as described in https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code-and-common-code-problems.
I must have been doing it wrong, I always use a 4 wire (kelvin) connection for accurate readings for low omic values.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.


