During this lesson, we will go through the process of reading sensor data, the TMP36 temperature sensor to be precise. First lets describe the sensor in more detail. The TMP36 (ebay) has a linear voltage to temperature output meaning there is no error correction to be calculated from our end, the sensor handles it brilliantly on its own. The following are some details taken directly from the datasheet:

Size: TO-92 package (3leads)

Price: around and under $1.00

Temperature range: -40°C to 150°C

Output range: 0.1V (-40°C) to 2.0V (150°C)

Power:2.7V to 5.5V , 0.05 mA current

The sensor is accurate up to around 125°C, beyond that increasing error margins are to be expected.

It has 3 leads

Pin 1 – Vin (+2.7V – +5.5V)

Pin 2 – Analog Voltage Output

Pin 3 Ground

TMP36-pinout

Lets get started with connecting the sensor to our Arduino. Connect Pin 1 to +5V on the Arduino, Pin 3 to Arduino GND and Pin 2 to A0 on your Arduino.

Thats all, now how are we going to read temperature through an analog pin? So the sensor wil output a voltage of 10mV per centigrade starting at 500mV offset to allow for sub Zero temperatures. Having said that, we know we need to convert the analog reading on the Arduino (0-1023) to mV. Using the below formula we can achieve this with ease.

result in mV = (A0 reading)*(5000/1023)

The 5000 refers to the maximum the Arduino analog pin can read. So when using 3.3V Arduino like the Pro Mini, replace the 5000 with 3300. Now all that’s left is to convert mV to centigrade.