Retired Product

This is a retired product. There is an updated version available: SEN-11931

Creative Commons images are CC BY-NC-SA 3.0

Description: Replacement:SEN-11931. We’ve updated a few reported issues with this board, go check out the new version! This page is for reference only.

This is a breakout board for the incredibly small TMP102 digital temperature sensor. The TMP102 is a digital sensor (I2C a.k.a. TWI), has a resolution of 0.0625°C, and is accurate up to 0.5°C. The sensor requires very low-current, and is loaded with features.

Communication with the TMP102 is achieved through a two-wire serial interface. There is no on-board voltage regulator, so supplied voltage should be between 1.4 to 3.6VDC. Filtering capacitors and pull-up resistors are included as shown.

Features:

  • 12-bit, 0.0625°C resolution
  • Accuracy: 0.5°C (-25°C to +85°C)
  • Low quiescent current
    • 10µA Active (max)
    • 1µA Shutdown (max)
  • 1.4V to 3.6VDC supply range
  • Two-wire serial interface

Documents:

Customers Also Purchased

Customer Comments

  • It would be great if SparkFun would supply example code in PicAxe BASIC as well as the ATmega and ARDUINO

    • A little late but try: (I have the address pin connected to ground)
      i2cslave %10010000, i2cslow, i2cbyte
      readi2c 0, (b0,b1)
      sertxd(“Byte 1 of the Temp Reg is: ” ,#b0,13,10)
      sertxd(“Byte 2 of the Temp Reg is: ” ,#b1,13,10)
      To change the device configuration: (i.e. Shutdown + Extended Mode)
      writei2c 1, (%11100001,%10110000)
      readi2c 0, (b0,b1)

  • Will Sparkfun be making more of these? I like the tiny size versus the SEN-11931 breakout.

    • Currently, we won’t be. The new revision is larger to accommodate the mounting holes on the board, to enable a more secure connection. However, this may be something we change in the future depending on user feedback (just as this was changed in the new version to accommodate the mounting holes).

  • Hey Guys!

    Am a newbie in PIC programming. I recently purchase this tmp102 breakout board for my school project. Am trying to read the temperature register with PIC16F877A using CCS Compiler. I connect the SDA and SCL to the SDA and SCL pins of the PIC respectively and ADD0 to ground. The tmp102 is powered with 3.3vcc. Everything went weird as what am getting is 255(0xFF) and 255(0xFF) for the MSB and LSB respectively. This might not be the appropriate place to post this challenge, but has any one done something related to this or can link me to other resources?

    Here is the code am using in CCS C

    // tmp102 code
    #include  
    #FUSES NOWDT                     
    #FUSES HS                        
    #FUSES NOBROWNOUT                
    #FUSES NOLVP, PUT 
    
    #use delay(clock=20000000)
    #use i2c(Master, sda=PIN_C4,scl=PIN_C3) // Configure Device as Master
    #use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=UART, ERRORS)
    
    #define TMP_RD       0x72
    #define TEMP_REG    0x00
    
    void main()
    {
    
    delay_ms(2000);         
     fprintf(UART,"TMP102 Example \r\n");
     fprintf(UART,"Reading Started...\r\n");
     delay_ms(500);
     while (1)
       {
          unsigned int8 msb, lsb;
    
          i2c_start();   
          i2c_write(TMP_RD);      // Read from this I2C address, R/*W Set
          delay_ms(50);
          i2c_write(TEMP_REG);       //Set pointer regster to temperature register  
          msb= i2c_read(1);            //Read the MSB data
          lsb = i2c_read(0);            //Read the LSB data
          i2c_Stop();
    
          printf(" %u ", msb); // check
          printf(" %u ", lsb);    // check
    
          delay_ms(3000); 
       }
    }
    

    Thanks

  • I did a little project to get back into electronics using this sensor and your Electric Imp breakout last weekend. This blog may help someone that has the same idea :) http://techgurka.blogspot.com/2013/04/quick-temperature-graph-using-electric.html

  • This sensor is incredibly stable. I have used and abused it while experimenting (dropping it, etc), it is still going strong. Being digital, it is not necessary to take an average of 5 or so readings as is commonly done with analog sensors. IMO the easiest to use as far as code goes (maybe tie with the TMP36 or a thermistor). I have an Arduino mounted (in a box) on the outside of a snake cage, connected to this sensor placed in a box inside the cage. I use the Arduino to control heating (Arduino output to an NPN transistor circuit to a zero-volt-turnon SSR and LED for status.) Works nicely.

  • Hey Guys,

    I just want to give you a link to some example code written in C that I used to communicate with the TMP102 from my Raspberry Pi through its I2C ports - http://bit.ly/X8xZGi Hope it’s helpful!

  • How do I get this board to work with a Sparkfun Pro Mini (5V)?

    It works just fine on an Uno. I’m using a voltage divider to reduce current on V+ to 3.3v. I’m guessing that it has to do something with needing to add pullup resistors on A4 and A5 or possibly converting the current to 5v on A4 and A5, but can’t seem to find a wiring diagram on how to do that.

    • Not sure if this is the right solution or not, but I got the I2C interface to work between this breakout and the Arduino Pro Mini 5V by changing the following items from bildr blog for the TMP102 breakout board:

      1.) Created a voltage divider using a 10k and a 22K resistor to convert 5v down to 3.4 v. (for VCC on the TMP102 breakout board) This is just a temporary solution since I didn’t have a 3.3 voltage regulator handy.

      2.) Soldering wires to the unpopulated A4 and A5 pins on the Pro Mini and adding a 1K pull up resistor to each pin. I connected the pullup resistor to the 5v power supply. It wouldn’t work connected to 3.3v.

      Success!

  • I get this error when I try to compile the program using AVR studio for the Atmega328. In the file ic2.h I get this:

    error: ‘F_CPU’ uncleared (First used in this function)

    Code:

        //calculate bitrate division    
    bitrate_div = ((F_CPU/40001)/bitrateKHz);
    if(bitrate_div >= 16)
    bitrate_div = (bitrate_div-16)/2;
    outb(TWBR, bitrate_div);
    

    Any help guys?

  • Does this product have eagle file? or this is not OSHW.

  • I’m using the following code and it reads 31.86 F and -0.06 C It’s nearly 75 F in here. And it appears to be stuck on this numbers? Any ideas ? Thanks in advance, Rick

    //Arduino 1.0+ Only //Arduino 1.0+ Only

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

    include

    int tmp102Address = 0x48;

    void setup(){ Serial.begin(9600); Wire.begin(); }

    void loop(){

    float celsius = getTemperature(); Serial.print(“Celsius: ”); Serial.println(celsius);

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

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

    float getTemperature(){ Wire.requestFrom(tmp102Address,2);

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

    //it’s a 12bit int, using two’s compliment for negative int TemperatureSum = ((MSB > 4;

    float celsius = TemperatureSum*0.0625; return celsius; }

  • For anyone using a Raspberry Pi (or any other Linux device) there is support built into the kernel for these sensors using lm-sensors (so you don’t have to write your own drivers). Make sure the temperature sensors (LM75 I think) are compiled into your kernel as well as i2c-dev, then, as root:

    echo tmp102 0x48 > /sys/class/i2c-adapter/i2c-0/new_device

    Replace 0x48 with your address and tmp102 with whatever chip you have. I don’t have the 102, but have a bunch of TMP100’s I sampled a while back that work perfectly with this setup (using ‘tmp100’ instead of ‘tmp102’).

  • Here’s a perl script I made for use on the Raspberry Pi using the Adafruit Occidentalis OS.

    Run this script as root or sudo to output the current temperature in Celsius and Fahrenheit:

    #!/usr/bin/perl
    
    #Grab the data from the device (Addr0 pin tied to ground gets 0x48 address)
    $rawhex = `i2cget -y 0 0x48 0x00 w`;
    
    #Switch the position of the two bytes and convert to integer
    $decimal = oct("0x" . substr($rawhex,4,2) . substr($rawhex,2,2));
    
    #Shift right four bits (12 bit mode)
    $decimal = $decimal >> 4;
    
    $celsius = $decimal * 0.0625;
    $f = (9.0/5.0) * $celsius + 32;
    
    #Profit!
    print "C: $celsius, F: $f\n";
    
    • Just wondering if you’ve scripted something in perl to account for temperatures below 0º C. Trying to hash out a solution but having a hell of a time.

      • # see: https://metacpan.org/pod/Device::Temperature::TMP102
        
        my $lsb = ( $value & 0xff00 );
        $lsb = $lsb >> 8;
        my $msb = $value & 0x00ff;
        
        my $temp = ( $msb << 8 ) | $lsb;
        
        # The TMP102 temperature registers are left justified, correctly
        # right justify them
        $temp = $temp >> 4;
        
        # test for negative numbers
        if ( $temp & ( 1 << 11 ) ) {
        
            # twos compliment plus one, per the docs
            $temp = ~$temp + 1;
        
            # keep only our 12 bits
            $temp &= 0xfff;
        
            # negative
            $temp *= -1;
        }
        
        # convert to a celsius temp value
        $temp = $temp / 16;
        
  • I’m having trouble getting this to work with an Arduino. I have hooked it up to A4 and A5, and I have it on the 3.3V power supply with the reference pin tied to ground. When I use the Bildr code to try to test it, I’m only ever reading values of 0 from the device. that is, I will get a temperature reading of about 0.0625 degrees celcius no matter what. This is my first time using I2C, so I might have made some stupid mistake, or I could have a bad chip, who knows. Any help anyone can give would be awesome. Thanks!

    • Sorry to hear you are having troubles with this. It sounds like you have everything hooked up correctly and unless you are getting any weird errors from the code, shouldn’t be having trouble there either. Check your sensor to make sure there aren’t any shorted pins or damaged components and double check your wiring matches. If you still have trouble with it, let us know at techsupport at sparkfun dot com and we can help you out.

  • Has anyone used this thing with an MSP430??

    I’m trying to incorporate this sensor for a project. I’m using an MSP430 F169 on an Olimex development board. I already have an LCD working and displaying calculations based on the closures of two reed switches.

    I’m using Code Composer Studio V5, and I haven’t been able to read anything from the sensor. I have the I2C interface set up, and have been messing with all kinds of things, from addressing to timing, but I, for the life of me, cannot read a temperature.

    Any help would be greatly appreciated!!

    Thanks, Mike

  • If this temperature sensor outputs a digital signal why is it connected to the analog inputs of the Arduino?

    • That is a great question! The answer is that most of the I/O pins on modern microcontrollers can be used for multiple purposes. Those particular analog pins are also used by the ATmega’s I2C (“Wire”) bus interface. When you use the Wire library, those pins cease being analog inputs, and are instead used for I2C communications. See the Arduino site’s Wire library reference page for more information.

  • You guys might want to consider adding a pullup or pulldown resistor in the next revision. Without a connection on ADD0, the sensor stops transmitting valid data whenever there is electrical interference (a finger on the connections, for example). If anyone has this problem, tie ADD0 to ground (address 72) or V+ (address 73). Also, on the arduino, 3.3V is enough to register high on the I2C bus, so no logic converter is required.

  • I composed a blog on using the Speakjet with a PICAXE-18M2 and an I2C temp sensor TMP102 in PICAXE Basic code for another programming example. Less than 40 lines of code made a system that compares the last temperature reading to the current one, and speaks “hotter” or “colder” if it changes a degree or more. [http://dinsmorerobotlab.blogspot.com/2011/09/hottercolder-talking-temp-sensor.html]

  • Can these be cascaded on one bus? That is, can I connect 4 of these on a single bus and connect them to a netduino? I can’t remember if the i2c lets you do that or not…

    • Yep, I2C is designed to accommodate multiple devices on the same bus, as long as all the devices have different addresses. The ADDR pin on this part allows it to be set to one of four possible addresses (see the datasheet on how to do this). So as long as you configure each one to have a different address, you’ll be able to talk to four of them on the same bus.

  • Can the TMP102 be used with DEO-nano from terasic? Is there example assembly code for the TMP102? Thanks.

  • Argh! :) Been banging my head against this device for months now and i can’t get it to work in LabVIEW with an Arduino for the life of me. If anybody has this TMP-102 working in LabVIEW can you PLEASE post a link showing how you did it?

  • Board dimensions: 1cm by 1.3cm
    The chip is in the exact middle of the board.

  • BTW, here is the code in StickOS (on PIC32, ColdFire, etc.) to print the temperature in degrees C:
    > list
    10 dim r as byte, t[2] as byte
    20 let r = 0
    30 i2c start 0x48
    40 i2c write r
    50 i2c read t
    60 i2c stop
    70 print t[0]
    end
    > run
    25
    > _
    See: http://www.cpustick.com/index.htm

  • Though it is a trivial task, I figured that many people new to this sensor would look here for info as I have.
    To get an output in degrees F, someone going by the conversion formula might attempt to do ((Counts * 0.0625) * 9/5 + 32), but that will give you an incorrect result.
    The proper way is to first shift the °C/count scale to a °F/count scale, and for this step you must leave out the “+ 32” part of the equation. Only after you have multiplied your raw data by the 0.1125°F/count (0.0625°C/count * 9/5) scale factor do you add the 32°.
    The correct equation is therefore (counts * 0.1125) + 32.
    Trivial, but hopefully will save someone a few minutes of confusion. I used the code from the wiring example posted.

    • If you use an integer to store both the high and low bytes from the sensor to represent temperature, make sure you clear the 4 most significant bits (15:12) after doing a two’s complement conversion for negative numbers. Otherwise you will get incorrect (and frustrating) results. Keep in mind this is for a 12-bit temperature data format.

  • Oh, man… I was just about to buy a couple of these. Any idea when they will be back in stock?

  • There is a Netduino friendly example here:
    http://forums.netduino.com/index.php?/topic/906-sparkfun-tmp102-digital-temperature-sensor/

  • Why not make a breakout board for the TMP275 instead of this particular chip? Though the low current and large range are appreciated in this case, it’s voltage requirements are different than that of the vast majority of micro-controllers out there. It adds just a little more unneeded cost and complexity to circuit design. I can buy the TMP275 in a breakout board elsewhere, but I’d rather just get everything I need here.

  • Does this work in Standard mode?

  • Has anyone hooked one of these up to an arduino?

    • @day1ok:
      I have an Arduino duemilanove, and have the tmp102 working. I connected V+ to the 3.3v pin on the Arduino board. Ground and Add0 to ground. SCL to analog pin 5, and sda to analog pin 4. The Alt connection is not needed. Here is my code, to read the sensor and print it through the serial port. I hope it helps.
      @futzle: I borrowed your snippets of code. They, and the rest of your comments helped a lot. Thanks!

      include

      int i;
      byte res;
      byte msb;
      byte lsb;
      int val;
      void setup()
      {
      Serial.begin(9600);
      Wire.begin();
      i = 0;
      }
      void loop()
      {
      res = Wire.requestFrom(72,2);
      if (res == 2) {
      msb = Wire.receive(); / Whole degrees /
      lsb = Wire.receive(); / Fractional degrees /
      Serial.print(msb,BIN);
      Serial.print(“.”);
      Serial.print(lsb,BIN);
      val = ((msb) 4); / LSB /
      Serial.print(“: ”);
      Serial.print(val0.0625);/ convert to Deg C(>0!)*/
      Serial.print(“: ”);
      Serial.print(val,HEX);
      Serial.print(“\n”);
      delay(1000);
      }
      }

      • Hi Pedro,<br />
        Your inputs are very helpful. My codes are fine with compilation and upload to the Arduino microcontroller. But somehow, I did not see the OUTPUT in the serial monitor. Can you provide me further suggestion to resolve this problem?<br />
        Thanks in advane!

      • Using the code last posted by Pedro I’m getting the following error:
        In function ‘void loop()’:
        error: expected `)‘ before numeric constant
        related to the line of code:
        val = ((msb) 4); / LSB /
        Would anyone know of a fix for this?
        Also I’m assuming that the first line of code:

        include

        Should read:

        include

        How may I fix this error and have I included the correct library?

        • Donzi,
          I apologize. The system is not copying the characters correctly, and there is one line missing from the code. I tried to post the correct two lines, previewed it (it was ok), but when I posted it, the same thing happened. Let me try to explain those two lines in words. below, substitute ltlt by two “less than” characters together (shift left operator), and “gtgt: by two "greater than” characters, also together (shift right) operator. In the second line, there is an “or equal” operator. Let’s see if this helps you. If it doesn’t you may want to open a temporary email account and I’ll send you the code. Here are the two lines:
          val = ((msb) “ltlt” 4); / MSB /
          val “or”= (lsb “gtgt” 4); / LSB /
          If anybody has an idea of why this is happening, I’d appreciate any comments.

          • The #include should read: “lt"wire.h"gt”. I’ll send the code to sparkfun and may be the’ll post it as one of the documents. There may be other missing lines or characters.

            • Sorry about all the runaround. It is not possible to post the code here. I posted it at this sparkfun board:
              AVR Atmel - Code
              I hope it helps

        • Donzi:
          Sorry. The copy command missed the two in the line that follows. The line that follows is also missing. I am wondering if those characters are “non printable” on this page. The correct code is this one:
          val = ((msb) 4); / LSB /

  • futzle: I contend that connecting A0 to GND (72) or V+ (73) are the only reliable options.
    I’m not even convinced of this any more. With A0 wired straight to V+, my TMP102 was responding happily on address 72. Then switched to 73 spontaneously after a few hours.
    I’m going to stop fighting it, and wire A0 straight to ground. If I need another temperature sensor on my household I2C bus I’ll have to look for a different brand.

    • Futzle were you able to even read off of it? I was able to Start, send the address(R/W bit low), get the proper ACK, set the pointer to the temp register, got the proper ACK, Stop. Then I attempted to start, send the address (R/W bit high) to read by get an ACK of [clock high]:[sda low] during all clock pulses after that the sda is alway high. Am I doing something wrong. Do I have to put a delay between the ACK and then expecting the actual data bytes to be read?

      • Hi Chachee,
        Yes, I’m getting readings off it right now, at address 72 now that I have A0 connected to ground.
        My Arduino code is essentially:
        byte res = Wire.requestFrom(72,2);
        if (res == 2)
        {
        ??byte msb = Wire.receive(); / Whole degrees /
        ??byte lsb = Wire.receive(); / Fractional degrees /
        ??/ Do stuff, in my case Serial.print() /
        }
        I don’t bother to write to it first; it seems to respond to a slave read all by itself.

  • tz: So, if I leave the A0 pin unconnected, it acts like it is grounded, i.e the address is 1001000?
    I’d say that the absence of an answer in the spec means “then don’t do that”.
    I lost a couple of hours today trying to talk to the TMP102. Figuring that with A0 in line with SDA on the breakout, I’d save having to cut the stripboard between the two pins. The datasheet puts that configuration at address 74. But respond it didn’t. Only by accident did I find that it was listening on address 73 all along, as it is supposed to when connected to V+. I contend that connecting A0 to GND (72) or V+ (73) are the only reliable options.

  • So, if I leave the A0 pin unconnected, it acts like it is grounded, i.e the address is 1001000?
    Or is it pulled up or something else? (Hard to tell from the data sheet - it doesn’t say it requires a pullup, but then it doesn’t say what it does if not connected to anything, only if connected to any pin but ALERT).

    • A0 is pulled up by a 1k pull-up resistor.

    • I gave this a try. It acts like it’s grounded, but it’s not really reliable. If you touch the board at all, it’ll get confused and think it’s tied to something else.
      Best to just solder a jumper to GND to be safe.

Customer Reviews

No reviews yet.