Averaging Thermistors from Raw values

I have 2 thermistors connected to my mega. Right now, The thermistor library dumps degrees in F for each. What I have done is for a "rate" of 1000 millis I add each reading and then increment a counter so I know 1. the total all of those temperature and 2. the amount of readings that make up that sum. I then divide the total by the readings number to get an average over about one second. This means that each reading requires math to come up with the values (all of them) and then more math to computer the average. What I would like to do is take the raw read from each, add THAT then divide by the number of readings THEN convert to a temperature one time. I believe that this would further streamline the sketch. I have checked online, but to no avail. I am calling on the wisdom of this forum to see if this is possible to do.

here is the way I average the temperatures:

temperature = temp.getTemp();
  tempTotal = tempTotal + temperature;
  tempReadings = tempReadings + 1;

  gtemperature = gtemp.getTemp();
  gtempTotal = gtempTotal + gtemperature;
  gtempReadings = gtempReadings + 1;
  //////////////////////////////////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////CALCULATE TEMERATURE AVERAGES///////////////////////////////////////////
  if ((currentRate - previousRate) > rate) {
    tempAverage = 0;
    tempAverage = tempTotal / tempReadings;
    rounded_up = ceilf(tempAverage * 100) / 100;

    float avgForpH = ((rounded_up - 32) / 1.8);
    gtempAverage = 0;
    gtempAverage = gtempTotal / gtempReadings;
    float grounded_up = ceilf(gtempAverage * 100) / 100;

Sure, you could average the raw reads. I can't think of any obvious problem with that, except that averaging depends on a linear reading, and the raw thermistor response is non linear. So the accuracy would suffer.

I havent the slights clue how to do that and since I cant find an example, not too sure what to do.

So don’t do it. The first method you explained should work fine.

Puzzled that you say that you don’t know how to do it since you did explain your proposal. I assumed that you understood your own proposal. :slight_smile:

Love it when I answer my own questions... Thanks for letting me know it is possible.

tempTotal = tempTotal + wRawADC;
  tempReadings = tempReadings + 1;

  gtempTotal = gtempTotal + gRawADC;
  gtempReadings = gtempReadings + 1;

  //////////////////////////////////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////CALCULATE TEMERATURE AVERAGES///////////////////////////////////////////
  if ((currentRate - previousRate) > rate) {
 wavgADC = 0;
    wavgADC = tempTotal / tempReadings;
    Resistance=((10240000/wavgADC) - 10000);
    wtemp = log(Resistance);
  wtemp = 1 / (0.001129148 + (0.000234125 * wtemp) + (0.0000000876741 * wtemp * wtemp * wtemp));
  wtemp = wtemp - 273.15;  // Convert Kelvin to Celsius

 wtempA = (wtemp * 1.8) + 32.0; // Convert to Fahrenheit
 roundedforph = ceilf(wtemp * 100) / 100;
 rounded_up = ceilf(wtempA * 100) / 100;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
    gavgADC = 0;
    gavgADC = gtempTotal / gtempReadings;
    gResistance=((10240000/gavgADC) - 10000);
    gtemp = log(gResistance);
  gtemp = 1 / (0.001129148 + (0.000234125 * gtemp) + (0.0000000876741 * gtemp * gtemp * gtemp));
  gtemp = gtemp - 273.15;  // Convert Kelvin to Celsius

 gtemp = (gtemp * 1.8) + 32.0; // Convert to Fahrenheit
 grounded_up = ceilf(gtemp * 100) / 100;