You're probably looking at an absolute calibration error. The +/-4C tolerance of the suggested temperature sensor is .. quite horrid, and is what you're seeing here.
Actually, if you look further. Typical specification is +/-2C for all sensors, but may vary from -4C to +6C (!!). That's basically a range of unknown of almost 10 degrees.
You could calibrate the sensor , and as long the slope is accurate, you're still getting a pretty absolute measurement. How accurate? Well, how accurate can you calibrate temperature.
If you assume your reference tells you the measurements are always +3C off, then sure .. subtract -3C from the output and leave it there. May not be very accurate because you're assuming your reference is spot on, and at exactly the same temperature as your sensor is. Even if you did manage that, the sensor would probably have a terrible drift over time as well..
Anyway, on the formula of the input. If you do got the MCP9701, then:
$$V_{0C} = 400mV$$
$$T_C=19.5mV/C$$
$$V_{OUT} = T_C \cdot T_A + V_{0C}$$
$$ \implies 19.5 \cdot T + 400 = output$$
If you want to measure up to about 45 to 50C, you could use the internal reference of the Arduino controller. This is 1.1V for an ATMEGA328. The useful thing about this is that you aren't using the power supply as a reference, which is pretty worse if you want somewhat accurate readings.
At 1.1V, you can calculate a new formula:
The offset is 400mV. 10-bit ADC means that 1.1V will get divided into \$2^{10}\$ steps, which is 1024.
\$\frac{1.1V}{1024}=1.07mV\$ per step
400mV means that you have bytecode 373.8 if the temperature sensor is reading 0C. This is your offset samplecode.
The slope is 19.5mV. ONce again .. 19.5/1.07 is 18(.2) per degree.. So, you could say that the samplecode is derived from:
$$samplecode=373.8+18.2 \cdot T$$
$$T=\frac{samplecode-373.8}{18.2}$$
For anyone interested in knowing how I solved this problem, I used the AREF and 3.3V from the Arduino microcontroller connected directly one of sides of the thermistors. I believe the voltage coming out of my laptop was dropping; USB +5V was dropping to ~4.7V thus making my calculations lower.
Here's the website which helped to find my answer (this site includes CODE and DIAGRAM):
http://learn.adafruit.com/thermistor/using-a-thermistor
Thanks everyone for your help.
Best Answer
Typically for electronic components, there is a datasheet available which explains most of the stuff you need to know.
The TMP36 isn't different in that regard. So the datasheet is published by Analog Devices.
In it you will fine important ratings like which supply voltage range the device is made for (2.7V - 5.5V).
And of course there is a specification on the behavior of the temperature sensor.
Table 4 on page 8 gives us the values you find in your code:
Which is what you are calculating.
Every sensor will be different and every will come with it's own specification. There are temperature sensors around with a digital interface, so you might have to do no conversion at all or have to calculate a strange polynomial function to get to the temperature.
I think the tutorial is a bit lacking in not telling you that there is a datasheet available. Datasheets are one of the most important things for engineers.
More complex devices (like a microcontroller) often come with a reference manual which covers the same stuff for all devices of a family and then there is a datasheet for each of the devices (or small family of devices).