Inaccurate and unsteady resistance measurement

Hello,

I'm kinda new to Arduino and would be needing help with an Arduino nano based gas sensor circuit I'm working on. The sensing mechanism is based on a change in the initial resistance of the sensor material. In my code, the initial resistance R1 of the sensor (before exposure to target gas) and final resistance of the sensor R2 (after exposure to target gas) are captured and sensitivity (related to gas concentration) is computed with the formula S% = ((R2-R1)/R1)*100.

Since the gas sensor is a chemi-resistor, I am using a simple voltage divider circuit to measure the changing R1 & R2. There's a 60 seconds delay after R1 is measured, to allow for sensor response when exposed to the target gas and R2 is then measured. The known resistor is an 18MOhm resistor, the unknown resistor (sensor) has an initial resistance of about 5MOhm and when exposed to the target gas, rises to about 35-40MOhm.

My problem is that the measured R1 and R2 values most times are inaccurate, unsteady and sometimes goes as low as 0.02MOhm and stays there. I have included a low pass filter with a cut-off freq. of 5Hz and an op-amp voltage follower at the Vout, before feeding the Arduino nano Analog input A0 pin. I have read where it says including a 0.1uF capacitor at the analog input A0 may help to steady the readings. When I do this, the R1 and R2 readings stay constantly at 0.02MOhms and doesn't change even with exposure to the target gas. The values are steady and normal only when I replace the sensor with a regular 10MOhm resistor. I'm also using a DHT11 to track the humidity and temperature changes.

I'll really appreciate some assistance as this is my final year project and I'm kinda new to using Arduino. I have included my code below...

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>




#define DHTPIN 2 
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);


int analogPin = 0;
int raw = 0;
int Vin = 5;
float Vout = 0;
float Ri = 18000000; //known resistor
float R1 = 0; //unknown(sensor resistance)
float buffer = 0;
float R2; //final resistance
float s;

void setup() {
 
  Serial.begin(9600);
  Serial.println("CLEARDATA"); 
  Serial.println("CLEARSHEET"); 

 
  Serial.println("LABEL, DATE, TIME, RH %, TEMP *C, S %, R1 *MOhm, R2 *MOhm, Glucose mg/dL");
  
  dht.begin();
}

void loop() {
  
delay(2000);

float h = dht.readHumidity();

float t = dht.readTemperature();


raw = analogRead(analogPin);
if (raw)
{
  buffer = raw * Vin;
  Vout = (buffer) / 1024.0;
  buffer = (Vin / Vout) - 1;
  R1 = (Ri * buffer)/1000000;
 delay(60000);
}

raw = analogRead(analogPin);
if (raw)
{
  buffer = raw * Vin;
  Vout = (buffer) / 1024.0;
  buffer = (Vin / Vout) - 1;
  R2 = (Ri * buffer)/1000000;

  s = ((R2 - R1) / R1) * 100;
}

if (isnan(h) || isnan(t) || isnan(s) || isnan(R1) || isnan(R2)) {
  Serial.println("Failed to read from Humidty & Acetone sensor!");
  return;*/
}
Serial.print("DATA,DATE,TIME,");
Serial.print(h);
Serial.print(",");
Serial.print(t);
Serial.print(",");
Serial.print(s);
Serial.print(",");
Serial.print(R1);
Serial.print(",");
Serial.println(R2);

delay(10000);

}

Please post a hand drawn schematic diagram of the complete circuit, with parts, pins and modules identified and values stated. Image posting guide

The analog inputs require the source impedance to be 10K Ohms or less.

Thanks jremington. Please find circuit diagram attached. Your help is appreciated!

Image posted properly:

Are you really using a uA741 op amp? That dinosaur could be about the worst possible choice for such a high impedance input circuit.

Note: In a conventional schematic diagram, signals flow from left to right. Power at the top, ground at the bottom.

Thanks for the correction on the conventional flow of signals. Please how could it be possibly harming my circuit and any suggestions on a suitable alternative to the uA741? Thanks.

The bias current of the 50 year old uA741 might be 100 nA, which flowing through an 18M resistor leads to a voltage drop of 1.8V. The input offset current is equally large.

Just look for a modern high input impedance op amp, like the OPA2107 and make a unity gain buffer. You will need a PCB with a guard ring around the op amp input circuit, and extremely clean construction technique.

Did you check the supply voltage with an oscilloscope. Some Arduino boards have noisy voltage regulators because they support such a large Vin range.

Tesla_tamer:
Thanks for the correction on the conventional flow of signals. Please how could it be possibly harming my circuit and any suggestions on a suitable alternative to the uA741? Thanks.

AD8656 is CMOS input, so bias current is about 1pA, which yields an error of only about 20µV with that 18M resistor! Its a 5V-supply rail-to-rail device so no need for extra supplies, and its low input-offset too.

Cheaper alternative would be a jelly-bean JFET opamp like the TL071

The µA741 belongs in a museum!

Thank you all for your suggestions. This has been resolved. I threw out the 741. Cheers.

Tesla_tamer:
Thank you all for your suggestions. This has been resolved. I threw out the 741. Cheers.

It belonged in a museum anyway... :slight_smile: