ATMEGA Core Temperature Sensor

Summary of ATMEGA Core Temperature Sensor


This article details a project using the ATMEGA32u4 microcontroller's internal temperature sensor to estimate ambient room temperature. The author configured the ADC with a 2.56V reference and multiplexer settings specific to the ATMEGA32u4, noting that while Arduino Leonardo and Pro Micro boards work directly, other AVR chips require register adjustments.

Parts used in Einstepper Project:

  • ATMEGA32u4 microcontroller
  • Einstepper Project board
  • Arduino Leonardo
  • Arduino Pro Micro

Abstract:

I recently stumbled across an interesting fact in the datasheet for the ATMEGA32u4, the microcontroller I am using for my Einstepper Project. I was surprised to find that Atmel had included a temperature sensor in the core of the device that you can read using the internal ADC. As it turns out, there are many megaAVR devices contain an internal temperature sensor. According to Atmel’s product finder, these devices are:
ATMEGA Core Temperature Sensor

  • AT90PWM161
  • AT90PWM81
  • ATmega168A
  • ATmega168P
  • ATmega168PA
  • ATmega16M1
  • ATmega16U4
  • ATmega328
  • ATmega328P
  • ATmega32M1
  • ATmega32U4
  • ATmega48A
  • ATmega48P
  • ATmega48PA
  • ATmega64M1
  • ATmega88A
  • ATmega88P
  • ATmega88PA

I was interested to see what temperature the microcontroller idled at and if this sensor could be used to detect the temperature of the room. By using a known temperature differential between the ambient air and core, it should be possible to calculate the ambient temperature. The Arduino Leonardo and Arduino Pro Micro use the ATMEGA32u4 so all the code below should work without modification. For other AVR boards that use a different chipset, minor modifications to the registers will be necessary.

Hardware:

I am using one of the boards from my Einstepper Project, but any board with one of the supported chips should work. There may be varying thermal characteristics between different packages (TQFP vs QFN) as well as different chips. These results are specifically for the ATMEGA32u4 in the TQFP package.

Software:

The first step was to setup the ADC to be able to read the internal temperature sensor. In order to use the temperature sensor correctly, you must set the ADC reference to the 2.56V internal reference, set the multiplexer to the temperature sensor, and enable the ADC. The code I used to configure the ATMEGA32u4′s temperature sensor is as follows. This is specifically for the ATMEGA32u4 so if you are using a different chip, you should check the datasheet for the correct register values.
 
 
For more detail: ATMEGA Core Temperature Sensor
 

Quick Solutions to Questions related to Einstepper Project:

  • Can the ATMEGA32u4 internal temperature sensor be used to detect room temperature?
    Yes, by using a known temperature differential between the ambient air and the core, it is possible to calculate the ambient temperature.
  • How do you set up the ADC to read the internal temperature sensor?
    You must set the ADC reference to the 2.56V internal reference, set the multiplexer to the temperature sensor, and enable the ADC.
  • Which Arduino boards use the ATMEGA32u4 chip?
    The Arduino Leonardo and Arduino Pro Micro both use the ATMEGA32u4, allowing the provided code to work without modification.
  • Do all megaAVR devices contain an internal temperature sensor?
    No, only specific devices listed in Atmel’s product finder contain this feature, including various ATmega and AT90 models.
  • What happens if I use a different chipset on an AVR board?
    Minor modifications to the registers will be necessary because the configuration code is specifically for the ATMEGA32u4.
  • Does the package type affect the results of this project?
    Yes, there may be varying thermal characteristics between different packages such as TQFP versus QFN.
  • Where can I find the list of supported microcontrollers?
    The list of supported devices can be found according to Atmel’s product finder.
  • Is the provided code applicable to all AVR boards?
    No, the code is specifically for the ATMEGA32u4, and users should check the datasheet for correct register values on different chips.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top