TMP36 Temperature Sensor and Arduino

The TMP36 is an analogue sensor, that needs to be read using the Arduino’s analogue input. The sensor outputs a voltage that is proportional to the temperature and is packaged in a transistor like TO92 format. The sensor can operate at either 5 volts or 3 volts, but interestingly will produce greater accuracy when operated at 3 volts. Unfortunately because it is an analogue sensor it is difficult to use on a Raspberry Pi.


As the analogue input on the Arduino produces 1024 ‘steps’, so if the maximum voltage is 3.3 volts then each step is

 Voltage at pin in milliVolts = (reading from ADC) * (3300/1024) 

This formula converts the number 0-1023 from the ADC into 0-3300mV (= 3.3V)

Then, to convert millivolts into temperature, use this formula:

Centigrade temperature = [(analog voltage in mV) – 500] / 10

This formula allows for temperatures below zero.

The ADC in the Arduino uses an internal reference voltage of 5 volts, but this can be changed by using


Then connecting the new reference voltage to the AREF pin. In this case we connect the Arduino’s 3.3 volt output to AREF and the connections are shown in the diagram at the top of this page.

Upload the following code and switch to the Serial Monitor to see the temperature sensor in action.

TMP36 temperature sensor test sketch
The TMP36 has three pins, with the flat on top and looking at the pins
Connect leftpin to Arduino 3.3v, and connect Arduino AREF to 3.3volts
Connect centre pin to Arduino pin 15 (A1)
Connect right pin to Arduino Gnd

#define aref_voltage 3.3 // Connect 3.3V to ARef

//TMP36 Pin Variables
int tempPin = 1; //the analog pin the TMP36's Vout (sense) pin is connected to

//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int tempReading; // the analog reading from the sensor

void setup(void)
analogReference(EXTERNAL); // If you want to set the aref to something other than 5v

void loop(void) {

tempReading = analogRead(tempPin);
Serial.print("Temp reading = ");
Serial.print(tempReading); // the raw analog reading

// converting that reading to voltage, which is based off the reference voltage
float voltage = tempReading * aref_voltage;
voltage /= 1024.0;

// print out the voltage
Serial.print(" - ");
Serial.print(voltage); Serial.println(" volts");

// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree with 500 mV offset
//to degrees ((volatge - 500mV) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");

// now convert to Fahrenheight
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s