# Arduino, Thermistors, LM4040, and the ADS1115

Hi all, I'm trying to read a thermistor using an external ADC with 16 bit precision, the ADS1115. Accuracy is important to me so I've also employed an LM4040 to provide a very steady voltage, specifically I used the model that is supposed to take a 3v3 input and give a 2v048 output.

My main issue here is that every document I've ready discussing how to convert the mV analog reading into a Resistance value assumes that the entire circuit is 5V so it cancels out two voltage readings at some point leaving the equation

I.e.

How can I correctly modify this formula to reflect the fact that my Vcc (3v3) is different than my actual analog input (1v526)

I think I'm on the right track, I found the following formula

Rt = (Rs)(Vin - Vout)/(Vout)

Where Rt is the Resistance of the thermistor, Rs is a fixed resistor value (10K for me), Vin is the measurement of my analog input, and Vout is the voltage being supplied as my voltage reference.

Can anyone confirm?

Here’s the code I’m using right now I’m getting a reading of negative 29 degrees C when it’s definitely only about positive 21 degrees C in the house, so I know I’m doing something wrong, I just can’t work out what.

``````#include <Wire.h>
#include <math.h>

#define NUMSAMPLES 5

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

}

void loop()
{
int16_t Results;
float temp, R, Vo, average;
float B = 3982; // B Coefficient
float Vcc = 2048; // Vin represented in millivolts
float To = 298.15; // Nominal temperature in Kelvin
float Ro = 10000; // Nominal Resistance of Thermistor
float Rs = 10000; // Value of fixed resistor
float multiplier = 0.0625F; // multiplier to convert ADS1115 into millivolts

// Take an average of readings
average = 0;
for (int i = 0; i < NUMSAMPLES; i++)
{
average += float(Results)*multiplier;
delay(10);
}

Vo = average / NUMSAMPLES;

// Convert Vo to Resistance value of thermistor

//!!!!! ----   I'm pretty sure this is where I'm going wrong --- !!!!!
R = (Rs*(Vcc-Vo))/Vo;

temp = R/Ro;
temp = log(temp);
temp /= B;
temp += 1.0 / To;
temp = 1 / temp;
temp -= 273.15;

Serial.println(temp);
delay(5000);

}
``````