Arduino and TMP100

As you can see from my previous articles, I’m a big fan of I2C. There are many components and full devices that can connect through I2C, today we’ll be looking at the TMP100. This is one in a family of digital I2C temperature sensors from Texas Instruments; they all function in a similar way but have slightly different features. Sensing temperature is a useful function to incorporate in your projects. Whether you are creating a thermostat, monitoring computer temperatures or building a beer brewing system, you need to know the temperature (and sometimes it helps to know the temperature from several different spots).

The TMP100 has 2 features that made me choose it over the other versions:
1) It supports input voltages of 2.7v to 5.5; as opposed to the 102 which needs to be between 1.4v and 3.6v
2) It has 2 address pins which allows for up to 8 of these sensors on a single I2C bus

One Tiny Chip

The TMP100 comes in the very tiny SOT23 package. This is a surface mount device (SMD), because of its size you’ll need a breakout board to work with it on a breadboard. This brings up the issue of soldering SMD components. Sparkfun offers both the breakout board and some great tutorials on soldering SMDs. I ended up soldering it with a 3rd hand, magnifying glass, tweezers and patience.

TMP100 Soldered on Breakout Board

TMP100 Addresses

The I2C address of the TMP100/101 is determined by the ADD0 and ADD1 pins.

ADD1ADD0I2C ADDRESS
001001000
0Float1001001
011001010
101001100
1Float1001101
111001110
Float01001011
Float11001111

This means you can include up to 8 of these chips into a project.

TMP100 Accuracy

The accuracy or resolution with which the TMP100 reads the current temperature is able to be configured by the user. By default it reads the temperate in 0.5 degrees Celsius increments but can be as accurate at 0.0625 degrees Celsius. This feature is set by writing the desired value to the configuration bit. This accuracy comes at a price which is the speed it can calculate the temperature. More accuracy means slower chip. See the table below for the exact trade off.

BitsResolutionConversion Time
9Bits(0.5°C)40ms
10Bits(0.25°C)80ms
11Bits(0.125°C)160ms
12Bits(0.0625°C)320ms

Wiring

In this example I’ve connected the chip to an Arduino and grounded ADD0 to set the address to “1001011”

TMP100 to Arduino Wiring

Sample Sketch

This code has 2 configurable settings at the top, the TMP100 address (as defined in the table above) and the temperature resolution.

// Display TMP100 readout to serial
// Fork Robotics 2012
//

// Set the TMP Address and Resolution here
int tmpAddress = B1001011;
int ResolutionBits = 10;

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  SetResolution();
}

void loop(){
  getTemperature();
  delay(200);
}

float getTemperature(){
  Wire.requestFrom(tmpAddress,2);
  byte MSB = Wire.read();
  byte LSB = Wire.read();

  int TemperatureSum = ((MSB << 8) | LSB) >> 4;

  float celsius = TemperatureSum*0.0625;
  float fahrenheit = (1.8 * celsius) + 32;

  Serial.print("Celsius: ");
  Serial.println(celsius);
  Serial.print("Fahrenheit: ");
  Serial.println(fahrenheit);
}

void SetResolution(){
  if (ResolutionBits < 9 || ResolutionBits > 12) exit;
  Wire.beginTransmission(tmpAddress);
  Wire.write(B00000001); //addresses the configuration register
  Wire.write((ResolutionBits-9) << 5); //writes the resolution bits
  Wire.endTransmission();

  Wire.beginTransmission(tmpAddress); //resets to reading the temperature
  Wire.write((byte)0x00);
  Wire.endTransmission();
}

I have to give credit to the guys at bildr for the getTemperature function. They have an article about the TMP102 which is very similar. See their write up here: http://bildr.org/2011/01/tmp102-arduino/

Summary

The TMP101 is a simple, easy to implement component that can be integrated into many projects. In addition to this direct, continuous way of reading temperatures it’s also possible to do more with this chip. It has a shutdown mode that can save power and allow you to get a single temperature on demand instead of the chip reading it constantly; a great feature for a battery powered device. If you don’t need as many devices in your project you can check out the TMP101 and TMP102 which can function in Thermostat mode where the Alert Pin will go high when a certain temperature threshold is passed.

One thought on “Arduino and TMP100

  1. Pingback: Cosm and TMP100 » Fork Robotics | Fork Robotics

Leave a Reply