Diode temperature sensor update…

November 21, 2011 | Arduino | By: Mark VandeWettering

Lee mentioned that the there was a way to change the analog reference used on the analog inputs to the Atmel AVR to an internally generated 1.1V, which would give me a lot greater resolution (about little over 1mV per step). Indeed, a little quick searching yielded that it was not only true, but dead simple: the Arduino provides an “analogReference” call. If you simply call it in your setup() routine with the argument INTERNAL, you’ll get a 1.1V reference.

To test it out, I did another run, pretty much the same as before, but illustrating the values read after changing to the internal 1.1V reference. Again, I began with the diode in air, then pinched it, released it, pinched it, then released it, then placed it next to a cold can of Diet Coke I had sitting next to me.

Seemed to work pretty well!

Kragen mentioned that the Atmel also had in internal temperature sensor as well. Indeed, it appears that you can simply do an analogRead(8) to access an internal “virtual pin” that links to an internal temperature sensing node. (On the Arduino Mega boards, the pin will be a different one) Read about it more here. I’m currently just using an old ATMega168 which doesn’t seem to have that capability, so I haven’t tested it. It appears that the sensor is noisy and uncalibrated, but it might be useful in some applications. When I dust off one of my more recent boards, I’ll give it a try.

Okay, time for breakfast.

Comments

Comment from Kragen Javier Sitaker
Time 11/21/2011 at 8:33 am

Oh, the temperature sensor was added in the 328 and wasn’t present in the 168? I didn’t know that. The datasheet that tells about it is labeled “ATMega48PA/88PA/168PA/328P” (doc8161.pdf); maybe the 168PA is like a newer version of the 168? There’s another datasheet out there for the “ATMega48/88/168” (2545S.pdf, with a “/V” suffix to each on the title page) which doesn’t document any temperature-measurement feature.

Comment from Mark VandeWettering
Time 11/21/2011 at 8:40 am

That’s my understanding. I haven’t tried it, but since I read the caveat in one of the forum posts that I read, I didn’t want to lead anyone astray (although I suspect that most of the Arduinos out there are 328 based). Thanks for making me aware of this anyway: I’ve got a project where it might be useful/interesting nonetheless.

Comment from Josh M
Time 11/21/2011 at 10:20 am

I use the temperature sensor in the ATTiny85 to seed the random mode on the SMD Badge kit (http://www.appliedplatonics.com/badge/), it works pretty well.

Comment from John Yale
Time 11/23/2011 at 8:48 am

On the 328 the internal reference is 2.56V rather than the 1.1V of the 168. Three diodes in series would give you the best resolution on the 328.