Shop OBEX P1 Docs P2 Docs Learn Events
New Object Posted - TMP102 Digital Temp Sensor — Parallax Forums

New Object Posted - TMP102 Digital Temp Sensor

photomankcphotomankc Posts: 943
edited 2015-01-16 06:24 in Propeller 1
Hey all,

It's been a couple of years now since I was actively doing much in the prop world. Been looking to evaluate some new temperature sensors for the breadboard thermostat running my home AC. The +/- 1 degree resolution on the DS1620 has not been enough to deal with summer A/C. Asking the A/C unit to pull the upstairs down by 2 degrees in the mid summer was proving to be too much and it would run the system for hours trying to catch back up.

I picked up a few contenders for a new temp sensor and the SparkFun breakout for the TMP102 looked real interesting. I think this will be a real contender. Practical resolution is awful close to 0.1*F which should make it possible to easily hold a 1 degree window on the A/C as well as be far more sensitive.

I decided while I was at it to go ahead and implement everything I could from the datasheet to make a nice all-round object. Didn't see it listed in the exchange so I posted it on up there. If anyone has the sensor and the time I'd love to hear if there are errors or if I missed something useful. At present I don't have a way to test handling negative temps so I did not implement that yet. I think it would be possible to test the first bit and negate the number. We shall see once winter sets in (or someone says, hey dummy do it this way).

http://obex.parallax.com/objects/search/?q=TMP102&csrfmiddlewaretoken=e20cc6de7bd0916ff1fce0d0d7780ae1

Comments

  • ManAtWorkManAtWork Posts: 2,176
    edited 2014-05-05 04:25
    Hi photomankc,

    thanks for the object, I'm using it in my latest project.

    I found out that the above link is broken. Here is the new one:
    http://obex.parallax.com/object/606

    And I have extended the code so that it now supports negative temperatures. There are only a few lines to change:
    PUB SampleTemp | msb, lsb, inbuff, delay, tD, tMS 
    ...
      msb:= (msb<<24)~>20             ' Assemble the shifted MSB and LSB
    
    PRI TempToCountC (tempC) | rounding
    ...
      if ||rounding => 5
        if rounding>0
          tempC++
        else
          tempC--
    
    PRI CountToTempC (countC) | calcTemp, rounding, finalTemp
    ...
      if ||rounding >= 500
        if rounding>0
          finalTemp++
        else
          finalTemp--
    
    PUB GetTempFracC
      return ||getTempC // 10 
    
    ... and of course the same for the °F functions.
  • photomankcphotomankc Posts: 943
    edited 2014-05-05 06:14
    Nice catch on the negative temps! Didn't test for that... doh! I'll see if I can roll those changes into my object.
  • ManAtWorkManAtWork Posts: 2,176
    edited 2014-05-05 06:48
    I've just tested with ice spray that it works at least basically. I can't guarantee that there's no bug in the rounding, though. The readings change so fast you can't tell if it's exact. But the rounding math could be tested with some static test cases.

    If we didn't need °F units we could eliminate the rounding altogether because the msw already contains the exact whole part and the lsb the fractional part. But I know... the goal was maximum flexibility not maximum efficiency.
  • nomorebotsnomorebots Posts: 6
    edited 2015-01-15 17:49
    Has anyone used a TMP102 with a k-type thermocouple to measure things? Are there any help or example out there? So far I've only found examples on the TMP102 by itself.

    Thanks.
  • kwinnkwinn Posts: 8,697
    edited 2015-01-16 06:24
    nomorebots wrote: »
    Has anyone used a TMP102 with a k-type thermocouple to measure things? Are there any help or example out there? So far I've only found examples on the TMP102 by itself.

    Thanks.

    The TMP102 is a single chip temperature measurement system with an on chip sensor. No way to add a thermocouple to it. You need to use one of the chips that are designed to be used with a thermocouple.
Sign In or Register to comment.