In some boards which environment temperature goes up could cause high temperature in micro controller. This will effect on micro and bad situation maybe occurs. For example I have designed a device which used in a box. This box was near a motor and after some load to motor I encountered a high temperature near micro. So, anyone could help me if there is any solution for finding temperature of micro? This micro could be AVR or PIC. If micro could find it's temperature, it could terminate working before any bad damage.


At least some (I don't know about all of them) AVRs have a temperature sensor on-chip, which is connected to the ADC.

The temperature measurement is based on an on-chip temperature sensor that is coupled to a single ended ADC channel. The sensor is a diode that produces a temperature dependent voltage. This voltage is measured with the ADC. The voltage has a linear relationship to temperature and the result has approximately a 1 LSB/°C correlation to temperature.

(from this application note)

A number of PIC devices also have an internal temperature indicator, like the PIC16F15xx and 16F18xx.

This family of devices is equipped with a temperature circuit designed to measure the operating temperature of the silicon die. The circuit’s range of operating temperature falls between -40°C and +85°C. The output is a voltage that is proportional to the device temperature. The output of the temperature indicator is internally connected to the device ADC. The circuit may be used as a temperature threshold detector or a more accurate temperature indicator, depending on the level of calibration performed. A one-point calibration allows the circuit to indicate a temperature closely surrounding that point. A two-point calibration allows the circuit to sense the entire range of temperature more accurately.

(from this datasheet)

Further reading
AVR122: Calibration of the AVR's internal temperature reference, Atmel application note,
Using the AVR internal temperature sensor,
PIC16F15xx datasheet, p.133
AN1333: Use and Calibration of the Internal Temperature Indicator, Microchip application note,

  • \$\begingroup\$ What is your recommendation for PIC micro? Is there any solution for PIC micro controller? \$\endgroup\$ – mehdi Sep 30 '12 at 13:20
  • \$\begingroup\$ @medhi - updated my answer. \$\endgroup\$ – stevenvh Sep 30 '12 at 13:34

Some micros come with temperature sensors built in. There are some PIC 16, for example, but I don't remember the specific model numbers. On other PICs, the watchdog timer interval is a predictable function of temperature. You can determine temperature with a initial calibration and then measuring the watchdog interval at run time. None of these methods are very accurate, but if you only need a rough idea of too hot, then might be good enough.

For anything else, use a external temperature sensor. There are many available, both digital and analog. If you have a spare analog input pin on the micro, then a simple analog sensor will probably be easiest. Otherwise, you will need to use something like IIC, SPI, or one-wire.

  • \$\begingroup\$ Timing variation sounds interesting, but does the watchdog vary enough more than the internal RC clock source does to be able to measure against it? Or would this only work with a crystal as a clock source? \$\endgroup\$ – Chris Stratton Sep 30 '12 at 18:15
  • \$\begingroup\$ @Chris: The app note I saw on this a long time ago may have been before PICs commonly had internal oscillators. Look around on the Microchip site and you may find it, then it should tell you more. I have never actually done this, but I definitely remember seeing a appnote on this subject. It could have been over 10 years ago. \$\endgroup\$ – Olin Lathrop Sep 30 '12 at 19:09

The PIC16F1503 is one that has an internal temperature sensor. Others are the PIC16F1526/7/8/9.

  • \$\begingroup\$ You're just too late, Leon. I just added that to my answer :-) \$\endgroup\$ – stevenvh Sep 30 '12 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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