Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is an exercise that about temperature measurement with a thermistor as intr

ID: 3769285 • Letter: T

Question

This is an exercise that about temperature measurement with a thermistor as introduced in lecture using the Adafruit thermistor tutorial. I just got some problems. And I just post the rule that my teacher asked and my questions with code that I have right now.

// which analog pin to connect
#define THERMISTORPIN A0   
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25   
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000

int samples[NUMSAMPLES];

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

void loop(void) {
uint8_t i;
float average;

// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
}

// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;

Serial.print("Average analog reading ");
Serial.println(average);

// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);

float steinhart;
steinhart = average / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert


Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");

delay(1000);
}

Explanation / Answer

// which analog pin to connect
#define THERMISTORPIN A0        
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000     
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25  
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000   

int samples[NUMSAMPLES];

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

void loop(void) {
   uint8_t i;
   float average;

   // take N samples in a row, with a slight delay
   for (i=0; i< NUMSAMPLES; i++) {
    samples[i] = analogRead(THERMISTORPIN);
    delay(10);
   }

   // average all the samples out
   average = 0;
   for (i=0; i< NUMSAMPLES; i++) {
      average += samples[i];
   }
   average /= NUMSAMPLES;

   Serial.print("Average analog reading ");
   Serial.println(average);

   // convert the value to resistance
   average = 1023 / average - 1;
   average = SERIESRESISTOR / average;
   Serial.print("Thermistor resistance ");
   Serial.println(average);

   float steinhart;
   steinhart = average / THERMISTORNOMINAL;     // (R/Ro)
   steinhart = log(steinhart);                  // ln(R/Ro)
   steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
   steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
   steinhart = 1.0 / steinhart;                 // Invert


   Serial.print("Temperature ");
   Serial.print(steinhart);
   Serial.println(" *C");

   delay(1000);
}


void setup() {
Serial.begin(9600);
temp.fixedResistance(9870);
temp.coefficients( 1.009249522e-03, 2.378405444e-04, 2.019202697e-07);
Serial.println("T (C)");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote