NTC READINGS KEEP CLIMBING

Hi i am having a strange issue with my ntc readings they keep climbing. code is attached its over the 9000char limit of site.

however in the ntc example code they are stable

int ThermistorPin = 0;
int Vo;
float R1 = 100000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

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

void loop() {

  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T = T - 273.15;
  T = (T * 9.0)/ 5.0 + 32.0; 

  Serial.print("Temperature: "); 
  Serial.print(T);
  Serial.println(" F"); 

  delay(1500);
}

sketch_apr10b.ino (9.56 KB)

The values "totalBed" and "totalHotEnd" are incremented with the last reading for each loop. You cannot calculate an average of the last "numReadings" readings like you do, so that is one problem :slight_smile:

this code is way past my level but im trying so bare with me...
thats for the running average tho is it not? ie: const int numReadings = 15;
so the way i read it is to collect the temp 15 times and then divide for an average

i noticed original code is using a digital pin on the mq2 so I have commented that out to see if it made a difference as well as changing max temp limits to 1000

temp seems to stop at 136~7 and stabilizes

c0ryp1:
this code is way past my level

So.. Start with something on your level and work you way up! :slight_smile:

but im trying so bare with me...

I'll bear with you while you take your clothes off. I'll be keeping mine on, though.

right .... anyways math seems to be correct after I got home from work I set my heat bed at different temps and took some resistance readings to check how far off my coefficients for the NTC were. after I did this temps were still stabilizing around ~133 and then while looking at the resting temp of my hotend before preheating to 200 I realized room temp was 13.7 according to the machine read out and then it hit me measured my resistors and sure enough 470kohm they were mislabeled of the paper that holds them neat.
set proper resistor value in the sketch viola temp readings correct.
I think the temps climb at the beginning due too it completing the loop before it has all 15 readings!

moving Serial.print to my if (readIndexHotEnd >= numReadings) statement solves temp climb issues on startup