0
\$\begingroup\$

Suddenly, after testing my NTC thermistor (100k), the thermistor's curve started to turn into a PTC curve. To measure the resistance I am using an Arduino. I think its a hardware issue as I did not change my program at all. Is there a way to check it the resistance's that the Arduino outputs are correct? Could this be the problem, would it be the thermistors? The precision, I think, is also affected, some are too 5C others are to 1C.

#include <Wire.h>
#include <Arduino.h>
int ThermistorPin = 0, reffPin = 1;
int resistance = 10000;


void setup() {
  Serial.begin(9600);
}

void loop() {
  float avg = 0;

      for(int x = 0; x < 10; x++)
      {
        avg += volateToResistance();
        delay(50);

      }
      Serial.println(avg/10.0);
    delay(5);
}
float volateToResistance()
{
  float voltage = analogRead(reffPin) * 5.0/1023;  // takes in ausmmed 5 volts and calulates actutal voltage Ex if analogRead(reffPin) = 1023, then voltage will be equal to exactly 5 volts 
  float Vout= (analogRead(ThermistorPin) * voltage)/1023.0;
  return resistance * (voltage/Vout) -1;
}

enter image description here

\$\endgroup\$
23
  • 2
    \$\begingroup\$ A multimeter would be the classical way of measuring resistance. \$\endgroup\$ Nov 2, 2019 at 15:26
  • 1
    \$\begingroup\$ To measure the resistance you are using an ardunio and what circuit? \$\endgroup\$
    – τεκ
    Nov 2, 2019 at 15:26
  • 1
    \$\begingroup\$ The Arduino is not an ohmmeter so you need to show us the circuit you are using and insert a listing of your code. Have you measured the thermistors with an actual ohmmeter? \$\endgroup\$ Nov 2, 2019 at 15:27
  • 2
    \$\begingroup\$ @AdityaKendre an actual schematic would've been better (drawing them is not hard) than a wiring cartoon, but well, it helps, if you tell us which cables go where. \$\endgroup\$ Nov 2, 2019 at 15:43
  • 1
    \$\begingroup\$ Your code doesn't make sense to me. You calculate voltage, then multiply Vout by it, then factor it out in the return statement. You might want to add some comments. \$\endgroup\$ Nov 2, 2019 at 16:13

1 Answer 1

2
\$\begingroup\$

As general troubleshooting guide, if you question the thermistor, test it in isolation. Disconnect the thermistor from the circuit, and use a multimeter in resistance mode to measure its resistance... should show about 100 kohm. Grab the thermistor with your fingers to heat it, and verify that the resistance decreases. Then it's a NTC.

If the problem is not with the thermistor, it's the calculations. Your calculations don't look right to me but I can't say exactly what's wrong. You can't measure Vref as that's already the reference the ADC measures again -- it's like using a ruler to measure the length of the ruler.

As your thermistor is on the high side of the voltage divider and you measure across the lower resistor, you will measure higher voltage when a NTC thermistor heats up. Maybe this is what confuses you.

A warning about your setup; your voltage divider using a 100 kohm thermistor and 100 kohm resistor will together give 50 kohm impedance. Signal impedance is the resistance 'experienced' by the microcontroller ADC, or loosely how sensitive the signal is to disturbances. Arduino Uno uses the ATMega328 microcontroller, which needs lower impedance for ADC to avoid skewed measurements. The datasheet can tell you in detail but I vaguely remember it should be lower than 10 kohm at least. The easiest solution is to add a capacitor between A0 and GND. Any capacitor value 10 nF or higher is ok -- 100 nF and 1 uF are common values.

The precision, I think, is also affected, some are too 5C others are to 1C.

This may be due to the impedance mentioned above, some error in the calculation or natural variations between thermistors. (All thermistors only promise to follow the specifications within some percentage.)

\$\endgroup\$
3
  • \$\begingroup\$ some of those capture-a-sample-of-the-analog-input ADCs end up with negative voltages on the cap (from what I've seen), and that causes huge confusion on the next high-impedance sample. \$\endgroup\$ Nov 2, 2019 at 17:31
  • \$\begingroup\$ That's odd, do you have some link for that phenomenon? A big cap or slow sampling frequency should avoid such a problem, right? \$\endgroup\$ Nov 2, 2019 at 17:35
  • 1
    \$\begingroup\$ the behavior is what I recall explained the -90 millivolt input residual on a Teensy board. The engineer-in-charge added a unity-gain buffer, and RC output filter, and that behavior went away. There is no link. Without the ADC schematic and timing diagram, who know what really was happening. I was just helping debug. \$\endgroup\$ Nov 3, 2019 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.