NTC linearization and implementation on a microcontroller

ericgibbs

Joined Jan 29, 2010
21,451
hi andrew,
This Sketch is set for your thermistor.
It outputs Cdeg, Rth, ADCv, ADCcount as csv format string.
Use a program like Tera Term or Termite as a text logger on the serial output.
You can then load the csv file into a spreadsheet if required.

E
BTW: you edit the Tamb step from 5C to 1C and the 'i' cntr limit to 100 in order to see one degree increments.

C-like:
/* thermistor temperature profile 14/05/2023 ESP57
*/
#define ADCin1 0

float Rser = 10000; // Series resistor with Therm
float R0 = 10000;  // Therm resistance at 25C
float Bval = 3977; // Therm Beta value
float Ak = 14.6337; // Therm constants, enter as positive values
float Bk = 4791.842;
float Ck = 115334;
float Dk = 3.730535E6;

float Rth = 0;
float ADCvolt = 0;
int ADCcnt = 0;
float Vss = 5.0; //  supply Volts

float TambAvg = 0;
float Tamb = 25.0;
int i = 0;
int avg = 0;
void setup()
{
  Serial.begin(115200);
  Serial.println("NTCLE100E3 Vishay Thermistor");
}

void loop() {
  Tamb = 0;
  Serial.println("Cdeg  Rth    ADCv Count"); // column header

  for (i = 0; i <= 20; i++) { // reading 0C thru 100C at 5deg intervals
    Rth = R0 * exp(-Ak + Bk / (Tamb + 273.15) - Ck / (pow((Tamb + 273.15), 2)) - (Dk) / (pow(Tamb + 273.15, 3)));
    ADCvolt = Vss * (Rth / (R0 + Rth));
    ADCcnt = (ADCvolt / Vss) * 1024;
    Serial.print(Tamb);
    Serial.print(",");
    Serial.print( Rth);
    Serial.print(",");
    Serial.print( ADCvolt);
    Serial.print(",");
    Serial.println( ADCcnt);
    Tamb = Tamb + 5; // step 5 Cdeg's
    delay(1000);
  }
}
 
Last edited:

kalemaxon89

Joined Oct 12, 2022
389
Are you the same person as TS @andrew74 ?
If you are, you need to select which account you wish to keep. An administrator can merge all your posts under one user name.
Yes, it is the same. Unfortunately many times I had problems with my main account "andrew74": wrong/changed passwords, disconnections also on other sites (google first of all) etc ... for a while I thought that someone stole the password in fact I wrote to Google support. In fact, I had to create this new account.
So sometimes it allows me to log in with that account and sometimes with this one, sorry for the confusion.
If you have to "merge" all the posts ... merge all the messages on this account from which I am writing because the other one has the problems I listed
 
Top