Measuring Temperature On An AVR Without A Sensor

There are a few AVR microcontrollers with onboard temperature sensors. These temperature sensors are neither accurate nor precise, but they do work for a few use cases. [Thomas] came up with a little bit of code that runs on all AVR microcontrollers, and is at least as accurate as the sensors in the rare AVRs that have them.

Although not all AVRs have a temperature sensor, they do all have RC oscillators, and these RC oscillators are temperature sensitive. By combining the RC oscillator and watchdog timer, [Thomas]’ code can get a vague idea if it’s getting hotter or colder.

To prove his code works, [Thomas] took an ATtiny13A chip loaded up with a few bits of code and placed a heated coin on it. The chip was programmed to turn on an LED when it detected a rise in temperature, and predictably, the LED lit up. With a coin chilled in a bowl of ice water, another bit of code ran, flashing the LED.

While we’re sure it’s neither accurate nor precise, it does have its uses – overheating protection or a simple thermostat. You can check out a video of the code in action below.

17 thoughts on “Measuring Temperature On An AVR Without A Sensor

    1. They definitely are sensitive to the power supply as I was playing with a half-completed IoT project.

      Taking a running average definitely cut down on some of the completely wild fluctuations I was seeing over a few seconds of time.

      When powered via a powered usb hub, every 30 minutes the readings would dip about 15F for about a 5 minute period before coming back up. Then I moved it to a USB wall charger and everything consistently read 40 degrees cooler but without the intermittent dip.

      1. This is most common answer to any criticism. It’s already quite lame counter-attack nowadays..

        Not the first “then go away” reply and not the first double-post here. I wish the writers could find the search button before writing a new post. Atleast mention “this has been posted here before but because .. (choose:) I cannot find search button I will post this again OR because we’re lacking good posts we post this again.. hey: it’s new project to someone!”

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.