The TMP102 is a very simple, yet accurate, ambient temperature sensor which is capable of detecting .0625ºC changes between -25 and +85°C, with an accuracy of 0.5°C. And the real kicker... It does all of this while only consuming 10µA (10 millionths of an amp). The thing is quite tiny, so SparkFun has put it on a breakout board to make things easier.

Naturally, you probably already ordered a few of these for your room-to-room sensor-network to prove to your landlord that the heat is dropping below the agreed temperature. Wait... That's just me? You just want to know how to hook one up to your Arduino? Ok... I can help with that.

The TMP102 is an I2C device, so when we are done with it, it will actually tell you the temperature, not send an analog signal that you then need to interpret. But that also means it is a little harder (code-wise) than just using an ADC and reading an analog voltage. But, in return for the added complexity, It is also more accurate then any analog reading the Arduino is capable of. So, if you actually care what the ambient temperature is, and not just checking to see if the temperature has changed, this is your guy. I say ambient temperature because it would be a little hard to connect this to anything, and it doesn't support a thermocouple.

For this, and all other I2C devices connected to your arduino, all you need to know is that I2C is a 2-wire serial connection, SDA (Data) and SCL (Clock) - On your Arduino (everything but the mega) SDA is on analog pin 4, and SCL is on analog pin 5. On an arduino mega, SDA is digital 20, and SCL is digital 21. Like most I2C devices, when communicating with one on an Arduino, we will be using the Wire library to do so.

The sensor has an address pin (ADD0) that is used to change the address the sensor is located at. This is useful if you need more than one of these hooked up to one Arduino, you can still call them independently even on the same bus. We are grounding this pin so that the sensor will use the address of 72 (0x48 in hex). Connecting this pin to V+ (3.3v on the arduino) would set the address to 73 (0x49 in hex), and you would just need to change that address at the top of the code ( int tmp102Address = 0x49; ).

The code for the TMP102 is the easiest I2C device I have yet run across, and accessing the value from it is just a few lines of code. To please the greatest ammount of people, we are going to output the values in both Celsius and Fahrenheit. But if you wanted to do the math, and had your reasons, you could output Réaumur or even Delisle.

Arduino 1.0 Compatible

//©2011 bildr
//Released under the MIT License - Please reuse change and share
//Simple code for the TMP102, simply prints temperature via serial

#include <Wire.h>
int tmp102Address = 0x48;

void setup(){

void loop(){

  float celsius = getTemperature();
  Serial.print("Celsius: ");

  float fahrenheit = (1.8 * celsius) + 32;  
  Serial.print("Fahrenheit: ");

  delay(200); //just here to slow down the output. You can remove this

float getTemperature(){

  byte MSB =;
  byte LSB =;

  //it's a 12bit int, using two's compliment for negative
  int TemperatureSum = ((MSB << 8) | LSB) >> 4; 

  float celsius = TemperatureSum*0.0625;
  return celsius;
Unless otherwise stated, this code is released under the MIT License - Please use, change and share it.


So, there you have it: Connecting the TMP102 digital thermometer to your Arduino. I hope this was helpful, and make sure to keep checking the site for more tutorials.