Resistance measurer for my lab

Dear All,

I am helping a research group at my university. They need to measure the value of the resistance of a material so I wrote a code for Arduino so they can measure the value of the resistance and also the conditions (I will include a DHT and a photoresistor later on, I have already work with them).

As long as my expertise is (bio)polymer (nano)composites more than arduino electronic and coding I have few questions that I would like to ask you.

Few questions:

The material should have a resistance value between 2 to 10 Mohms, and we need to measure it with an accuracy of 0.1 Mohms.

So I was thinking of putting a pull-out resistor of 100 kOhms. Or its better a pull-in is better to increase resolution? I have seen that usually its used 10 KOhms resistors, but in this case, I want to go a little bit upper to increase resolution. I am doing it right?

So, this is the code,

int TestPinIn = 3; //We will connect the material to this PWM pin, so potentially we can test the resitance in the range of 0-5 V.
int TestPinOut = 5; // The output of the material, this voltage shoudl give us the resistance.

float Vcc; //Voltage value provided by arduino (0-5 V).
float Vread; // Voltage value detected by arduino (0-1023)
float V; //Voltage value detected by arduino (0-5 V)

float Rvalue; // Value of the resistance
float Pullres = 10000; //value of the resistance of the resistor

void setup() 
{
pinMode(TestPinIn,OUTPUT);
pinMode(TestPinOut, INPUT);
Serial.begin(9600);
}

void loop() 
{
  Serial.println("Measure starting in 15 s");
  delay(5000);
  Serial.println("Measure starting in 10 s");
  delay(5000);
  Serial.println("Measure starting in 5 s");
  delay(5000);
  Serial.println("Measure starting now");
  unsigned long StartTime = millis();
  for( int x = 0 ; x < 255 ; x = x + 25 ) 
  { 
  analogWrite(TestPinIn, x); //the output voltage value of the pin that supplies electricity to the material will vary from 0 to almost 5 V
  Vcc = 5.0*(x/255);//Voltage provided by arduino
  float Vout = analogRead(TestPinOut); //Read how much voltage arrives to the detection pin
  V = Vout*(5.0/1023.0); // Conver the voltage value to 0 - 5 V from the 0-1023 of the analogread.
  Rvalue = Pullres*(Vcc/V -1);// https://en.wikipedia.org/wiki/Voltage_divider
  unsigned long CurrentTime = millis();
  unsigned long ElapsedTime = CurrentTime - StartTime;
  Serial.print("Time: ");
  Serial.print(ElapsedTime);
  Serial.print(" s; ");
  Serial.print("Vcc: "); 
  Serial.print(Vcc);
  Serial.print(" V; ");
  Serial.print("Vdetected: "); 
  Serial.print(V);
  Serial.print(" V; ");
  Serial.print("Resistance of the material: "); 
  Serial.print(Rvalue/1000.0);
  Serial.println(" kOhms; ");
  delay(500);
 } 
}

Arduino scheme.png

To get the best accuracy, you want to have the greatest range on your analogRead() values from Rmin (2M) to Rmax (10M) so your voltage divider should be about in the middle ~6 Mohm

Also, you might want to read up on what analogWrite acutally does. It produces a square wave output beteen 0 and 5 with a duty cycle (on vs. off). I don't think that will benefit your measurements. Just set your test pin HIGH and measure your input pin.

Finally, this line:

Vcc = 5.0*(x/255);//Voltage provided by arduino

isn't doing what you think. x is an integer so the compiler is free to do integer division of x/255 (which will always be zero) and then multiply by 5.0. You might want that to be 255.0. [Note: I don't have an arduino handy to verify this, so I may be wrong]

For "serious work" you should be using a real multimeter. (You can get multimeters with a computer interface.)

[u]PWM[/u] is NOT DC.

Also, note that the Arduno ADC measures voltage relative to its ground. (A regular DMM doesn't have an exposed/external ground.)

So I was thinking of putting a pull-out resistor of 100 kOhms. Or its better a pull-in is better to increase resolution?

If you're using a [u]voltage divider[/u] the fixed resistor value should be close to the unknown resistor value.

The material should have a resistance value between 2 to 10 Mohms, and we need to measure it with an accuracy of 0.1 Mohms.

That should be possible. The 10-bit ADC gives you about 0.1% resolution 1/1023). But, you won't get the full range from a voltage divider so you wont' get the full-percentage resolution.

I'm not following you math, but a voltage divider is not linear because it's a ratio of one resistance to the total resistance.

I will include a DHT and a photoresistor later on, I have already work with them

I don't know what you mean by DHT and I don't understand what a photoresistor is doing in this project...

I agree with the above recommendation to buy a good multimeter.

The Arduino is not at all suitable for making accurate resistance measurements, especially in the megohm range you are considering.

The input resistance of the Arduino ADC is not high enough for measuring such high resistances. Use a high-impedance amplifier in front of the ADC, or better both an amplifier and high resolution ADC combined in a single chip (INA...).

In DIY circuits nearby lines, dust and humidity can cause stray currents on a PCB, which will distort the measured values. So for reliable results a ready made multimeter really is the best choice.

If this is a geniune research project, you would assume that all 'measurements' are going to be done with instruments where you have tracebility of the calibration.

Hi,
OPs diagram;
a2aaeb714b7176f4be5c76e0e500ef89e05af60d.png

Tom… :slight_smile:

Dear All

Thank you very much for your kind replies! They have been really helpful.

blh64:
To get the best accuracy, you want to have the greatest range on your analogRead() values from Rmin (2M) to Rmax (10M) so your voltage divider should be about in the middle ~6 Mohm

Also, you might want to read up on what analogWrite acutally does. It produces a square wave output beteen 0 and 5 with a duty cycle (on vs. off). I don’t think that will benefit your measurements. Just set your test pin HIGH and measure your input pin.

I just wanted to prove that material´s resistance does not change with voltage. But I think that you are right, that can be skipped.

blh64:
Finally, this line:

Vcc = 5.0*(x/255);//Voltage provided by arduino

isn’t doing what you think. x is an integer so the compiler is free to do integer division of x/255 (which will always be zero) and then multiply by 5.0. You might want that to be 255.0. [Note: I don’t have an arduino handy to verify this, so I may be wrong]

I think that you are actually right about that. Thanks!

DVDdoug:
For “serious work” you should be using a real multimeter. (You can get multimeters with a computer interface.)

Thank you very much!. I didn’t know that they were multimeters with computer interface. The reason to use arduino is mostly to keep a detailed record and to ensure that all of the experiments are done in exactly the same way. (Thats why we need a DHT).

Furthermore, we are developing a sensor that ultimately could be put in an arduino to make cool stuff! Thats also why i thought on this platform.

DVDdoug:
[u]PWM[/u] is NOT DC.

Also, note that the Arduno ADC measures voltage relative to its ground. (A regular DMM doesn’t have an exposed/external ground.)

Thanks for the info. I will skip that part.
In this work we are more interested on tracking the “change” of the value of the resistance of the material rather than on the actual value.

DVDdoug:
If you’re using a [u]voltage divider[/u] the fixed resistor value should be close to the unknown resistor value.
That should be possible. The 10-bit ADC gives you about 0.1% resolution 1/1023). But, you won’t get the full range from a voltage divider so you wont’ get the full-percentage resolution.

Good point, I will check if a resolution of 1% is enough. For the present work, we are more interested in recording the variation of the values of the resistance to some stimulus.

DVDdoug:
I don’t know what you mean by DHT and I don’t understand what a photoresistor is doing in this project…

It is a generally good practice to try to record all of the possible information on how do you do your experiments and report them. Then other scientists might find flaws in your experiments.

For instance, the resistance of a material made out of nanocellulose and carbon nanotubes will change by quite a few orders of magnitude depending on the humidity (Actually, it has been proposed as humidity sensor).

For this reason, it is important that I record all of this information, so i can later on report on the paper that the materials were tested on those conditions.

srnet:
If this is a geniune research project, you would assume that all 'measurements' are going to be done with instruments where you have tracebility of the calibration.

Yes, in fact, the idea is that before we test the material, we will test few resistances in the range of the material, and compare real results with theoretical results of the resistance. Then we can prove that our arduino-based system does what we claim, measure correctly the resistance.

Regards,

Then other scientists might find flaws in your experiments.

An easy to spot, major flaw would be to use an Arduino, rather than using accurate, appropriately calibrated equipment for making resistance measurements.

If this is for publication, please educate yourself about how accurate, repeatable resistance and other types of environmental measurements are made. Consumer grade sensors are not acceptable.

jremington:
An easy to spot, major flaw would be to use an Arduino, rather than using accurate, appropriately calibrated equipment for making resistance measurements.

+1

Dear all,

Thank you very much for your feedback. I have understood that Arduino might not be good enough for this purpose. Therefore, I will seek a better equipment for the real measurements.

Then, I will probably also test them with Arduino and compare results.