Converting A0 voltage from NTC thermistor to Temperature

I didn't think this would be any problem but i can't seem to find the information i need, and yes I've looked and looked. I am working with an esp8266-12n, hopefully this is an ok place to ask about this as its more a math problem than a specific board problem i'm having. The control board went bad in the oven, a new one was $150, i decided i would save some $$ (at the expense of over a week now of planning, soldering, writing code).

Here is what i have physically, 5V ---> NTC thermistor ---> A0(through a 4051 multiplexer) ---> 2K Resistor ---> GND

A0 on this board is 0 - 3.3v, 0-1024

Here is a chart with the resistance to temp relationship of the thermistor,

I am using a 2k pot at the moment to simulate the thermistor. With the pot set to 1K, i get 1024 (and yes it just hits 1024 right at 1k), with it set to 2k, i get 764. So what i am trying to figure out is how to convert the value of A0 to the actual temperature.

Here is the code i have so far, it seems to be doing what i want it to do, with the exception of the temperature conversion issue. I am still quite the noob, started toying with a R3 Mega less than a month ago, no previous experience with microcontrollers, and a basic understanding of components (transistor/capacitor/diode/resistor etc.. I'm sure my code is horrible but it works lol. I would appreciate any assistance with this.

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

#define sA D5                  // 4051 Select Pin A
#define sB D6                  // 4051 Select Pin B
#define sC D7                  // 4051 Select Pin C

#define inputPin A0

#define bakePin D0             // bake transistor pin
#define broilPin D8            // broil transistor pin

int debounce = 750;            // delay for button debounce

int lcdRefresh = 500;          // how many ms between writes to lcd

bool bakeState = 0;            // used to keep track of the state of the bake transistor
bool broilState = 0;           // used to keep track of the state of the broil transistor
bool bakeEnabled = 0;          // flips from 1 to 0 with button press, enables tempControl() to turn on transistors for element relay's
bool broilEnabled = 0;         // flips from 1 to 0 with button press, enables tempControl() to turn on transistors for element relay's
bool tempHigh = 0;             // used to keep off loop from running over and over

unsigned long bakeButtonPrevMillis = 0;
unsigned long broilButtonPrevMillis = 0;
unsigned long lcdWriteMillis = 0;

int tempDesired = 0;        // holds desired temp
int temp = 0;               // holds temp reading


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

  lcd.init();   // initializing the LCD
  lcd.backlight(); // Enable or Turn On the backlight 
  
  pinMode(sA, OUTPUT);
  pinMode(sB, OUTPUT);
  pinMode(sC, OUTPUT);
  pinMode(bakePin, OUTPUT);
  pinMode(broilPin, OUTPUT);

}

void loop() {
  readBakeButton();                                   // see if bake button has been pressed
  readBroilButton();                                  // see if broil button has been pressed
  tempControl();                                      // control the temp if bakeEnabled or broilEnabled == 1
  
  if(millis() - lcdWriteMillis >= lcdRefresh){        // write to the lcd at "lcdRefresh" interval
    writeLCD();
  }

}



void tempControl() {
  readTempPot();      // read the temp set pot
  readTempSensor();   // read the ntc thermistor

  if (bakeEnabled == 1 && (temp <= tempDesired - 5) && bakeState != 1) {  // if bake is enabled, and temp is 5* lower than desired temp, and bake is not already on, run bakeOn()    
    tempHigh = 0;
    bakeOn();
    bakeState = 1;
  }
  if (bakeEnabled == 1 && temp >= tempDesired + 5 && tempHigh != 1) {     // if bake is enabled, and temp is 5* higher than desired temp, and tempHigh is not already 1, run bakeOff()
    tempHigh = 1;
    bakeOff();
    bakeState = 0;
   }
  if (bakeEnabled == 0 && bakeState != 0){                              // if bake is not enabled and bakeState is not already 0, run bakeOff()
    bakeOff();
    bakeState = 0;
  }

  if (broilEnabled == 1 && (temp <= tempDesired - 5) && broilState != 1) {    // same as above but for broil
    tempHigh = 0;
    broilOn();
    broilState = 1;
  }
  if (broilEnabled == 1 && temp >= tempDesired + 5 && tempHigh != 1) {
    tempHigh = 1;
    broilOff();
    broilState = 0;
   }
  if (broilEnabled == 0 && broilState != 0){
    broilOff();
    broilState = 0;
  }

}

void readBakeButton() {
  int a;
  digitalWrite(sA, HIGH);               // select the correct channel of the 4051 mulitplexer to read the bake button
  digitalWrite(sB, HIGH);
  digitalWrite(sC, LOW);
  a = analogRead(inputPin);             // read A0 and place value into int "a"
  //Serial.println(a);
  //delay(500);


  if (a <= 100 && (millis() - bakeButtonPrevMillis) >= debounce){     // if a is less than 100, assume bake button has been pressed

    if (bakeEnabled == 0){                                            // if bake is not already enabled, enable it
      bakeEnabled = 1;
      Serial.println("Bake ON (from readBakeButton() )");
      bakeButtonPrevMillis = millis();
    }
    else {
      bakeEnabled = 0;                                                // else disable bake
      Serial.println("Bake OFF (from readBakeButton() )");
      bakeButtonPrevMillis = millis();
    }

  }
}

void readBroilButton() {        // same as readBakeButton()
  int a;
  digitalWrite(sA, LOW);          
  digitalWrite(sB, LOW);
  digitalWrite(sC, HIGH);
  a = analogRead(inputPin);       
  //Serial.println(a);
  //delay(500);

  if (a <= 100 && (millis() - broilButtonPrevMillis) >= debounce){  

    if (broilEnabled == 0){
      broilEnabled = 1;
      Serial.println("Broil ON (from readBroilButton() )");
      broilButtonPrevMillis = millis();
    }
    else {
      broilEnabled = 0;
      Serial.println("Broil OFF (from readBroilButton() )");
      broilButtonPrevMillis = millis();
    }
  }
}

void bakeOn() {
  Serial.println("Bake ON");
  digitalWrite(bakePin, HIGH);
  }

void broilOn() {
  Serial.println("Broil ON");
  digitalWrite(broilPin, HIGH);
}

void bakeOff() {
  Serial.println("Bake OFF");
  digitalWrite(bakePin, LOW);
}

void broilOff() {
  Serial.println("Broil OFF");
  digitalWrite(broilPin, LOW);
}

void readTempPot() {
  digitalWrite(sA, HIGH);
  digitalWrite(sB, LOW);
  digitalWrite(sC, LOW);
  tempDesired = analogRead(inputPin);       
}

void readTempSensor() {
  digitalWrite(sA, LOW);
  digitalWrite(sB, LOW);
  digitalWrite(sC, LOW);
  temp = analogRead(inputPin);            // need to figure out how to convert this value to actual tempurature in *F
}

void writeLCD() {
  lcd.setCursor(0, 0);
  lcd.print("S: ");
  lcd.print(tempDesired);
  lcd.print(" ");
  lcd.print("A: ");
  lcd.print(temp);
  lcd.setCursor(0, 1);
  lcd.print("Bake:");
  
  if(bakeEnabled == 1){
    lcd.print("* ");
  }
  if(bakeEnabled != 1){
    lcd.print("  ");
  }

  lcd.print("Broil:");

  if(broilEnabled == 1){
    lcd.print("*");
  }
  if(broilEnabled != 1){
    lcd.print(" ");
  }
  lcdWriteMillis = millis();

  
}

I put your numbers into excel...

Assuming 5V > NTC > A0 > 2k > GND and external ref 3V3

x= analogRead(A0);
Temp_f = 0.00321x² - 7.73905x + 4602.7; // correlation factor 0.9996

(lowest temp 48F)

knut_ny:
I put your numbers into excel...

Assuming 5V > NTC > A0 > 2k > GND and external ref 3V3

x= analogRead(A0);
Temp_f = 0.00321x² - 7.73905x + 4602.7; // correlation factor 0.9996

(lowest temp 48F)

Thank You!!!

had to change it a little for the compiler to like it, i ended up doing this:

tempRaw = analogRead(inputPin);      
temp = 0.00321 * sq(tempRaw) - 7.73905*tempRaw + 4602.7; // correlation factor 0.9996