ATMEGA Core Temperature Sensor


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.


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.


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

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:

Leave a Comment

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

Scroll to Top