I want to know if there is a method to know the temperature of the microcontroller to avoid its over heat.

  • 2
    \$\begingroup\$ Measure the temperature and compare to the limits stated in its data sheet. Not sure what you really expect as an answer here. \$\endgroup\$
    – Solar Mike
    Apr 29 '20 at 4:12
  • \$\begingroup\$ Or use a simple PTC and the ADC of the controller \$\endgroup\$
    – Mike
    Apr 29 '20 at 4:37
  • \$\begingroup\$ This is usually designed out - few microcontrollers consume enough power that they are at risk of overheating, unless you're over-driving the GPIO. \$\endgroup\$
    – pjc50
    Apr 29 '20 at 12:35
  • \$\begingroup\$ If I measure the temperature and compare it all the time, then i will not do my project. The aim from this step is to do a preventive step to avoid any explosions \$\endgroup\$ Apr 29 '20 at 16:18

The vast majority of microcontrollers on the market today have some kind of built-in die temperature sensor. Often this is implemented as an extra channel on the ADC multiplexer. It may not be especially accurate, but should be fine for detecting an overheat condition.

  • \$\begingroup\$ Can you give me a type of microcontrollers? I read the specs of PIC microcontrollers and I do not find any embedded sensor \$\endgroup\$ Apr 29 '20 at 5:42
  • 3
    \$\begingroup\$ @Aymanhussien - you haven't read very far then. PIC16F18426, page 504, PIC18F27K40 page 546. And those were just the first 2 random samples I picked. \$\endgroup\$
    – brhans
    Apr 29 '20 at 12:25
  • \$\begingroup\$ these are good examples to start with. Thank you for your efforts to inform us with useful data \$\endgroup\$ Apr 29 '20 at 16:17
  • \$\begingroup\$ ATTiny and ATMega MCUs typically have an internal temperature sensor as well. \$\endgroup\$
    – Dampmaskin
    Apr 29 '20 at 16:36

There are million digital temperature sense IC. You can glue one to your CPU and connect to your MCU like any other IC. Just read the temperature directly.

It is important to know alot about the IC if you want to do this correctly. You need to know the thermal impedances of the IC to case, and case to ambient (or case to heatsink, then heatsink to ambient). THese values are found in the IC datasheet. The math is simple. If you can calculate the thermal impedances, you can indirectly approximate the temperature of your IC die.

  • \$\begingroup\$ That is a good and practical solution, but I need to decrease the number of used ports and consumed memory \$\endgroup\$ Apr 29 '20 at 5:43
  • 5
    \$\begingroup\$ @Aymanhussien It is not fair to the readers if you put new requirements in a comment. Add all of your requirements to the question itself. \$\endgroup\$ Apr 29 '20 at 12:07
  • \$\begingroup\$ My bad. I missed to add this in my question. But this is a real solution especially if my microcontroller does not include an embedded temperature sensor. \$\endgroup\$ Apr 29 '20 at 16:13

If you already have an I2C bus in your project you can hang a digital temperature sensor that has a unique address off the bus without consuming any additional I/O pins.

If there is no conflict between polling the temperature and other usage of the bus (which only you can decide) then you have a potential solution. An example of such a chip is the MCP9808, but you should evaluate the various offerings should you decide to go this way.


  • ±0.25°C (typical) from -40°C to +125°C

  • ±0.5°C (maximum) from -20°C to 100°C

  • ±1°C (maximum) from -40°C to +125°C

Not the answer you're looking for? Browse other questions tagged or ask your own question.