measure thermistor in 12v circuit w/ reference voltage

Hello and Thanks in advance.

I'm trying to solve for the resistance of T in the circuit. It's a thermistor (car coolant) that varies from 20k at low temps to 100ohms at high temps. The circuit diagram shows the A0 and A1 values being returned by arduino in my test circuit. The left voltage divider is the thermistor, and the right one is to serve as a reference voltage of the highest expected voltage.

I've already got the thermistor formulas, so that's not my issue - my issue is figuring out the proper formula to solve for T.

My application is vehicle coolant temp, so my source voltage is 12v, which is why the large resistor values. I've tried using AREF external, but I like the idea of being able to see what's going on with my reference voltage and calculate it manually. |500x338

Can anyone tell me how to solve for T, knowing R1(left), A0, R1, R2, and A1? I spent all day on this yesterday and could really use some help. Thanks again.

This is about ratios, of course.

Vout1 = Vin * T / (T + R1)

Vout2 = Vin * R2 / (R2 + R1)

A0 = 1024 * Vout1 / Vcc

A1 = 1024 * Vout2 / Vcc

A0 = 1024 * Vin * T / (T + R1) / Vcc

A1 = 1024 * Vin * R2 / (R2 + R1) / Vcc

A0 / A1 = (T / (T + R2)) / (R2 / (R2 + R1))

= T * (R2 + R1) / ((T + R2) * R2)

((T + R2) * R2 * (A0 / A1) = T * (R2 + R1)

T * R2 * (A0/A1) + R22 * (A0/A1) = T * (R2 + R1)

T * (R2 + R1 - R2 * (A0/A1)) = R22 * (A0/A1)

T = R22 * (A0/A1) / (R2 + R1 - R2 * (A0/A1))

Hope I did that correct :slight_smile: On paper it for sure goes easier than in a basic text editor.

Thank you very much for taking the time to work that out for me, it is much appreciated. I was unable to solve that on my own and was able to get it to work with a slightly different approach - I consulted with a very smart friend today who is better than I am at algebra, but he could not condense it down to a simple ratio.

You did manage to do it, however I cannot get your final equation to return a correct result in my code, so I suspect there is an error somewhere, either in my approach, or your formula. I appreciate your effort, but since this forum is used as a reference for lots of things, I thought I’d let you know so nobody else grabs it without further testing.

I’ve since upgraded to a 16-bit ADC and am getting the proper results by using the voltage divider on the right to establish exactly what vin is, then using that to solve for T in the left voltage divider, in two separate equations.

A0 and A1 are swapped places as drawn in my circuit diagram now and in this example code, so don’t get confused by that. It’s adapted from an adafruit example. I’ve also input the exact resistor values in the appropriate places in the code. It’s returning a result within 1 ohm of being a correct result, so I’m satisfied with that. I need to do some cleanup on it and incorporate it into my larger project. I’d be willing to try further condensing it down using your formula, but at this point I’m satisfied and can move on as well.

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads1115(0x48);  // construct an ads1115 at address 0x49
 
void setup(void)
{
  Serial.begin(9600);
  Serial.println("Hello!");
  
  Serial.println("Getting single-ended readings from AIN0.1");
  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
  ads1115.begin();
}

void loop(void)
{
  int16_t adc0, adc1;
  float volts0, volts1, volts3;
  float R;
  float vin;

  adc0 = ads1115.readADC_SingleEnded(0);
  adc1 = ads1115.readADC_SingleEnded(1);
  Serial.print("AIN0: "); Serial.println(adc0);
  volts0=(adc0 * 0.1875)/1000;
  Serial.print("AIN0v: "); Serial.println(volts0,7);
  Serial.print("AIN1: "); Serial.println(adc1);
  volts1=(adc1 * 0.1875)/1000;
  Serial.print("AIN1v: "); Serial.println(volts1,7);
  vin=volts0*(47630+20063)/20063;
 
  Serial.println(" ------ T ------");
  R=(volts1*47463)/(vin-volts1);
  //R=47000/((pow(2,16)-1)/adc1 -1); //assumes 5v vin
  Serial.print("AIN1r: "); Serial.println(R);

  delay(1000);
}

If it ain't broke, don't fix it.

You're probably not going to save any significant amount of memory, either.