Arduino Internal temperature sensor

Most AVR chips (microcontrollers) have an internal temperature sensor, hence we can use this option to get temperature range in rare condition, this might show higher than external temperature.

internal-temperature-new

List of AVR microcontrollers having internal temperature sensor given,

ATmega168A : Yes

ATmega168P : Yes

ATmega328 : Yes

ATmega328P : Yes

ATmega32U4 (Arduino Leonardo) : Yes



Refer your arduino board chip to know about the internal temperature sensor.

The internal temperature of microcontroller varies depends on its work load.

To measure temperature in degree Celsius.

temperature = (ADCW – 324.31) / 1.22;

Arduino Code

 

// Internal Temperature Sensor
// Example sketch for ATmega328 types.


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

  Serial.println(F("Internal Temperature Sensor"));
}

void loop()
{
  // Show the temperature in degrees Celcius.
  Serial.println(GetTemp(),1);
  delay(1000);
}

double GetTemp(void)
{
  unsigned int wADC;
  double t;

  // The internal temperature has to be used
  // with the internal reference of 1.1V.
  // Channel 8 can not be selected with
  // the analogRead function yet.

  // Set the internal reference and mux.
  ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
  ADCSRA |= _BV(ADEN);  // enable the ADC

  delay(20);            // wait for voltages to become stable.

  ADCSRA |= _BV(ADSC);  // Start the ADC

  // Detect end-of-conversion
  while (bit_is_set(ADCSRA,ADSC));

  // Reading register "ADCW" takes care of how to read ADCL and ADCH.
  wADC = ADCW;

  // The offset of 324.31 could be wrong. It is just an indication.
  t = (wADC - 324.31 ) / 1.22;

  // The returned temperature is in degrees Celcius.
  return (t);
}

 

Steps to Use Arduino Internal Temperature Sensor:

Step 1: Check the Arduino board Chip about Internal temperature sensor.

Step 2: Connect Arduino with system.

Step 3: Upload the Arduino code for Internal temperature sensor.

Step 4: Obtain the temperature reading in Arduino Serial Monitor.

 

Prototype

arduino-internal-temperature-serial-new




 

How it Works?

One thought on “Arduino Internal temperature sensor

Leave a Reply

Your email address will not be published. Required fields are marked *