TMP102 Example Code
  Updated 14 May 2012 by Noah Crowley

  Based on:
    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>

//The TMP102 has an address pin which can be used to change the I2C address
//of the sensor. In this example, that pin is tied to ground, which results
//in the sensor using an address of 72, or 0x48 in hexadecimal.
int tmp102Address = 0x48;

void setup(){

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

  delay(1000); //Delay for one second. You can remove this.

float getTemperature(){

  byte MSB = Wire.read();
  byte LSB = Wire.read();

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

  float celsius = TemperatureSum*0.0625;
  return celsius;