Hi.
As part of an arduino multimeter project , I had this issue where I had to measure resistance with arduino. I did it a couple of times with a voltage divider and different reference resistors , but it did not cover a satisfactory range (unless I used 100k Ohms which meant a lack of precision in small and large values alike )
So I decided to make multiple ranges . I searched google and found 2 websites and one forum topic , but the websites did not fix the issue about range - one of them had 220~22k resistors which would still mean issues in the million range , the other did not look like anything I was looking for.
But the forum post was interesting. someone suggested current mirrors
And I understand the concept of having similar currents and varying resistance and measuring voltage , but I do not understand which parts of the circuit need to be measured in order to do this.
Furthermore , I used the websites' schematics and changed them a bit to make this (the attached image) (sorry btw I did not have any proper schematic applications on my PC at this time)
and this is the code for the attached image:
float buf;
float buf2;
int ref;
float R2;
int analogPin = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
//call functions highend and lowend
lowend();
Serial.print("lowend: ");
Serial.println(R2);
if (R2 > 100000) {
highend();
Serial.print("highend: ");
Serial.println(R2);
}
Serial.println(" ");
Serial.println(" ");
delay(1000);
}
void lowend () {
digitalWrite(6 , HIGH);
digitalWrite(5, LOW);
buf = analogRead(analogPin);
buf = buf / 903;
ref = 10000;
buf2 = 1-buf;
buf=buf*ref;
R2=buf/buf2;
}
void highend () {
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
buf = analogRead(analogPin);
buf = buf / 903;
ref = 1000000;
buf2 = 1-buf;
buf=buf*ref;
R2=buf/buf2;
}
I also tried using transistors instead of diodes but I could not calculate the error caused by the transistors in order to remove it , so I had to use this method , but for some unknown reason this does not work either.
I do not understand why my code/circuit fails , and I dont understand how to use the current mirror method , and I have been searching but I cant figure out a way to measure resistance with the arduino reliably that can measure 100~10M Ohms.
Another thing I thought of was to use the Voltage/Current sensor I am using in the project to calculate resistance as well , but that somehow seems like a bad idea to me because of the method current sensors are placed in circuits and because yet again I cant figure out how to use it.
any help is more than appreciated
thanks in advance