Pages: [1]   Go Down
Author Topic: ATtiny44/84 built in temperature sensor  (Read 446 times)
0 Members and 1 Guest are viewing this topic.
NE Iowa
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I noticed on a datasheet that ATtiny44 and ATtiny84 have built in temperature sensors.  Is there a way to access the value of the chip's temperature?  I know its not good for ambient air temperature but curiousity runs wild with me.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, the datasheet describes it. I fiddled with it once on an ATmega328P but didn't really spend enough time with it to even know if I had it working right.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a sketch that seems to work with an ATmega328P-MU. I get around 365mV, which would be about 75°C according to the example in the datasheet. Room temp is currently around 26°C, so that seems a bit high, but it's not a precise thing. Can the internal chip temp be that hot? The package certainly isn't that hot. It does respond fairly quickly (increases) when I put my finger on it. So maybe it's just not well-calibrated.

I thought maybe this could be coded just with standard Arduino function calls, but I don't think so; I ended up manipulating the registers directly. Something similar should work with the ATtinies, but the register definitions are not identical, so be sure to review them.

Code:
#include <Streaming.h>    //http://arduiniana.org/libraries/streaming/

void setup(void)
{
    Serial.begin(115200);
}

void loop(void)
{
    float v;
   
    ADMUX = 0xC8;                 //channel 8
    ADCSRA = 0xC7;                //start the conversion
    while (ADCSRA & _BV(ADSC));   //wait for it to complete
    v = 1.1 * ADC / 1024.;
    Serial << _FLOAT(v, 3) << endl;
    delay(1000);
}
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Pages: [1]   Go Up
Jump to: