TMP35/36/37 sensors

The TMP36 (and TMP35 and TMP37) provide a voltage output that is linearly proportional to the temperature in Celsius, which makes them very easy to work with. Connect one to an analog input pin, and the value (between 0 and 1024) read from the pin can be converted to Celcius by this formula:
( ( sensor_value / 1024 * VCC_in_millivolts) - offset_value_in_millivolts ) / scaling_factor
For example, for a TMP36, it would be as follows:
( ( sensor_value / 1024 * 5000) - 500 ) / 10
Which can be simplified as:
( sensor_value * 500 / 1024 ) - 50
Or even:
( sensor_value * 49 - 5026 ) / 100
You can check the math using the reference mV at 25C.
Sensor | Offset voltage (mV) | Scaling (mV/C) | Output at 25C (mV) |
---|---|---|---|
TMP35 | 0 | 10 | 250 |
TMP36 | 500 | 10 | 750 |
TMP37 | 0 | 20 | 500 |