ieee488:
For a simple temperature measurement sketch this has turned out to be more complicated than I thought it would be. :o
Not that hard once you understand Aref.
Default Aref (if you don't do anything in code) is the board's supply.
If you use an Uno or Mega, that will be ~5volt.
Not so good to use for accurate measurements, because it's not that stable (dips from flashing LEDs, relays, motors, etc.).
Then there is an internally generated ~1.1volt Aref that you can call in setup.
analogReference(INTERNAL);
Not accurate (could be 1 to 1.2volt), but it is very stable.
A Mega also has a ~2.56volt Aref.
You can also provide your own Aref.
Connect a stable/accurate voltage to the Aref pin, and use analogReference(EXTERNAL); in setup.
There is a danger of connecting an external voltage to the Aref pin (3.3volt in the Adafruit link).
You have to make sure Aref is set to EXTERNAL.
When it's on default (forgot to change it in code), or you have set it to INTERNAL, the externally voltage will fight the 5volt or 1.1volt that is on the Aref pin.
Using a resistor eliminates that danger at the cost (or gain) of a slightly lower Aref.
See analogReference() - Arduino Reference
The TMP36 outputs 0-2volt with temps between -50C and +150C. This is a 200C span.
If you use default (5volt) Aref, you will have 2/5 * 1024 = ~410 A/D values to work with.
410 / 200 = About two values per degreeC. Not really enough for a temp readout to one decimal place.
If you use 1.1volt Aref, you can only measure 0-1.1volt. That is -50C to ~+60C. A 110C span.
But now you have 1024 values across that span, so 9.3values per degreeC. Ok for one decimal place.
Limitation is now ~+60C, but that shouldn't be a problem if only indoor/outdoor temps are measured.
If you make your own Aref, e.g. by connecting the 3.3volt pin to Aref (with a resistor), you can set the upper limit of your temp sensor as you please. At the cost of less A/D values per degree C.
Hope this explains it a bit.
Leo..