ist/enlighterjs.min How to Read Internal Temperature Sensor in Arduino
Type Here to Get Search Results !

How to Read Internal Temperature Sensor in Arduino



Temperature Measurement

The temperature measurement is based on an on-chip temperature sensor that is coupled to a single ended ADC input.


MUX[4..0] bits in ADMUX register enables the temperature sensor. The internal 1.1V voltage reference must also be selected for the ADC voltage reference source in the temperature sensor measurement. 

When the temperature sensor is enabled, the ADC converter can be used in single conversion mode to measure the voltage over the temperature sensor.

Example Code:

void setup() {
  Serial.begin(9600);
  Serial.println(F("Internal Temperature Sensor"));
}

void loop() {
  Serial.print(GetTemp(),0);
  Serial.println("C");
  delay(1000);

}

double GetTemp(void){                               // The internal temperature has to be used
  unsigned int wADC;                                  // with the internal reference of 1.1V.
  double t;                                                     // Channel 8 can not be selected with
                                                                     // the analogRead function yet.
 
  ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));        // Set the internal reference and mux.
  ADCSRA |= _BV(ADEN);                                                          // enable the ADC
  delay(20);                                                                                     // wait for voltages to become stable.
  ADCSRA |= _BV(ADSC);                                                          // Start the ADC
  while (bit_is_set(ADCSRA,ADSC));                                         // Detect end-of-conversion
  wADC = ADCW;                                       // Reading register "ADCW" takes care of how to read ADCL and ADCH.
  t = (wADC - 324.31 ) / 1.22;           // The offset of 324.31 could be wrong. It is just an indication.
  return (t);                                                                  // The returned temperature is in degrees Celcius.



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.