Tag Archives: tmp102

Temperature Sensor TMP102 with arduino

So after playing around with the Humidity sensor, it was natural for me to start playing with a simple temperature sensor. For my project, I choose the TMP102 sensor. The main reasons for choosing this sensor were:

a) I was working with a 3.3V Arduino, so I wanted a sensor that I could interface directly.

b) This sensor has great resolution, it is quite cheap (for less than $6) and sparkfun has a breakout board for the same.

c) It allowed me to play some more with the I2C interface.


Arduino makes it really straightforward to play with I2C with its Wire Library that is very well documented . The sensor has multiple modes and lot of additional functionality that can be configured over I2C.

This sensor also has an additional pin that can be used to get 4 different addresses on the I2C bus. In my experiment, I connected it to GND to get an address of 72.

Great Getting Started Tutorial is available from buildr website. I have just wrapped this code around a simple library that can be downloaded from here. This library currently works with the sensor in basic mode ( I will be updating it soon to allow access to the sensor’s extended functionalities).

UPDATE: The library for Arduino 1.0 and higher can be downloaded fromĀ from here

Below is some sample code to use the sensor:

#include "WProgram.h"
#include "Wire.h" // Required to talk to the sensor and read values
#include "TMP102.h"  //TMP102 library

using namespace std;

TMP102 tmp102;

void setup()
    tmp102.setup(); // Currently not required, but future versions of library will use it to set modes

void loop()
    // Get Temperature
    float tempC = tmp102.getTemperatureCelsius();
    float tempF = tmp102.getTemperatureFahrenhiet();

int main(void)
	for (;;)
	return 0;