Oversampling Code Help

I need to increase the resolution of a thermistor for a project I'm working on and oversampling seemed like a pretty good solution to that problem. I found this code and it seems to be exactly what I need, but when I run it, I don't get anything on the serial monitor. I feel like I'm missing something really obvious but I just can't find what it is. I know the thermistor is wired correctly because my other code works, just with lower resolution than I need. Here is the code:

#define BUFFER_SIZE 16 // For 12 Bit ADC data

volatile uint32_t result[BUFFER_SIZE];
volatile int i = 0;
volatile uint32_t sum=0;


/*
ADC and Timer1 setup function
  Argument 1: uint8_t channel must be between 0 and 7
  Argument 2: int frequency must be integer from 1 to 600
    WARNING! Any value above 600 is likely to result in a loss
    of data and could result in a reduced accuracy of ADC
    conversions
*/
void setupADC(uint8_t channel, int frequency)
{
  cli();
  ADMUX = channel | _BV(REFS0);
  ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0) | _BV(ADATE) | _BV(ADIE);
  ADCSRB |= _BV(ADTS2) | _BV(ADTS0);  //Compare Match B on counter 1
  TCCR1A = _BV(COM1B1);
  TCCR1B = _BV(CS11)| _BV(CS10) | _BV(WGM12);
  uint32_t clock = 250000;
  uint16_t counts = clock/(BUFFER_SIZE*frequency);
  OCR1B = counts;
  
  TIMSK1 = _BV(OCIE1B);
  ADCSRA |= _BV(ADEN) | _BV(ADSC);
  sei();
}

ISR(ADC_vect)
{
  result[i] = ADC;
  i=++i&(BUFFER_SIZE-1);
  for(int j=0;j<BUFFER_SIZE;j++)
  {
    sum+=result[j];
  }
  if(i==0)
  {
    double Temp;
    // See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
    Temp = log(((10240000/sum) - 10000));
    Temp = 1 / (0.001285 + (0.0002362 * Temp) + (0.00000009285 * Temp * Temp * Temp));
    Temp = Temp - 273.15;           // Convert Kelvin to Celcius

    double fTemp;
    double temp = Temp;  // Read sensor
    fTemp = (temp * 1.8) + 32.0;    // Convert to USA
    Serial.print("Temperature: ");
    Serial.print(temp);
    Serial.print(" C / ");
    Serial.print(fTemp);
    Serial.println(" F"); 
 
    sum = sum>>2;
    Serial.println(sum,DEC);
  }
  sum=0;
  TCNT1=0;
}

ISR(TIMER1_COMPB_vect)
{
}

void setup()
{
  pinMode(0, INPUT);
  Serial.begin(9600);
}

void loop()
{
  setupADC(0,40);
}

Any help would be greatly appreciated. Thanks in advance!

Have you heeded @MartT's advice...

Bear in mind that thermistors are sensitive and fast reacting. Don't confuse fluctuating readings with noise. When checking for noise, the temperature of the thermistor should be kept as stable as possible.

Will the system not having enough noise cause no data to be output? I was under the impression that it just reduced the accuracy of the reading.

mooch444:
Will the system not having enough noise cause no data to be output?

You need to first determine that oversampling will work. To do that, start with working code (yours) and run the experiment. After you have determined that oversampling will work then introduce something like the code in your first post.

I was under the impression that it just reduced the accuracy of the reading.

I don't understand.

From what I have read about oversampling, I thought that if a system did not have enough noise for it to oversample properly, you would lose the added resolution you were shooting for and it may decrease the accuracy of the readings. I am literally not getting any output on the serial monitor when I run the program, its just blank. It seems like I have an error in the code somewhere that is preventing serial output, not that the technique of oversampling will not work with this system. But I could be wrong. I will look into ways to introduce noise to the system and see if that helps.

It's better to move all printing and math from the ISR to the main loop:

  if(i==0)
  {
    double Temp;
    // See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
    Temp = log(((10240000/sum) - 10000));
    Temp = 1 / (0.001285 + (0.0002362 * Temp) + (0.00000009285 * Temp * Temp * Temp));
    Temp = Temp - 273.15;           // Convert Kelvin to Celcius

    double fTemp;
    double temp = Temp;  // Read sensor
    fTemp = (temp * 1.8) + 32.0;    // Convert to USA
    Serial.print("Temperature: ");
    Serial.print(temp);
    Serial.print(" C / ");
    Serial.print(fTemp);
    Serial.println(" F"); 
 
    sum = sum>>2;
    Serial.println(sum,DEC);
  }

And you also could increase serial baud rate , to 115200 or so.
Other thing, just notice, should be this line in setup?

  setupADC(0,40);