Parts: I2C Digital Thermometer (TC74)

tc74

Microchip’s TC74 is an inexpensive digital temperature sensor with a simple I2C interface. It has a resolution of 1 degree Celsius, and a range of -40 to +125 degrees. This is an easy way to add temperature measurement to a project without an analog to digital converter. We’ll show you how to use the TC74 below.

Microchip TC74 digital temperature sensor (Octopart search, starting at $0.88)

The TC74 comes in five pin through-hole and surface mount packages, see the TC74 datasheet (PDF). We couldn’t find a Cadsoft Eagle footprint for any version of this part, if you know of one please link to it in the comments.

tc74

Different versions of the TC74 are calibrated for specific voltages, but all work from 2.7-5volts. The TC74A5 we used is most accurate when operating at 5volts, but we powered it from a 3.3volt supply. The I2C connection needs 2 pull-up resistors to hold the bus high (R1, R2), 2K-10K should work. C1 is a 0.1uF decoupling capacitor.

We used the Bus Pirate universal serial interface in I2C mode to test drive the TC74, but the same principals apply to any microcontroller. We powered the TC74 from the Bus Pirate’s 3.3volt supply, and used the on-board pull-up resistors to hold the I2C bus high.

Command Value
Select temperature register 0x00
Select configuration register 0x01

The TC74’s write address is 0x9a, and the read address 0x9b. It has two, one-byte registers. Register address 0 holds the temperature reading, register 1 holds the configuration settings.

Configuration register

Bit 6 of the configuration register is 0 at power-on, and changes to 1 when the first valid temperature reading is available. Bit 7 is writable, and puts the TC74 in a power saving standby mode. Reading the register involves two steps: use a partial write command to select the register, then use the read command to retrieve the value.

I2C>{0x9a 1}
210 I2C START CONDITION
220 I2C WRITE: 0x9A GOT ACK: YES <–write address
220 I2C WRITE: 0x01 GOT ACK: YES <–select config register
240 I2C STOP CONDITION

First, we select the configuration register with a partial write command. This doesn’t actually write a value, it selects the register to read and write. { creates the I2C start condition, followed by the TC74 write address (0x9a) and the select configuration register command (0x01). } issues the I2C stop condition and ends the transaction.

Now we can read the contents of the register.

I2C>{0x9b r}
210 I2C START CONDITION
220 I2C WRITE: 0x9B GOT ACK: YES <–read address
230 I2C READ: 0x40 <– register value (01000000)
240 I2C STOP CONDITION
I2C>

The read address (0x9b) returns the one byte register value (r). The configuration register value, 0x40 or 01000000, shows that the device is out of standby (bit 7=0), and a valid temperature reading is available (bit 6=1).

The TC74 has a low-power standby mode. Enable it by writing 1 to bit 7 of the configuration register.

I2C>{0x9a 1 0b10000000}
210 I2C START CONDITION
220 I2C WRITE: 0x9A GOT ACK: YES <–write address
220 I2C WRITE: 0x01 GOT ACK: YES <–select config register
220 I2C WRITE: 0x80 GOT ACK: YES <–value to write (01000000)
240 I2C STOP CONDITION
I2C>

The register is written with single three-byte command. First we send the write address (0x9a), followed by the register to select (0x01), and finally the value to write (0x80). Only bit 7 of the configuration register is writable, the values of bits 6-0 are ignored.

Read the register again to verify that the command worked.

I2C>{0x9a 1}{0x9b r}
210 I2C START CONDITION <–first command sets register
220 I2C WRITE: 0x9A GOT ACK: YES <–write address
220 I2C WRITE: 0x01 GOT ACK: YES <–config register (1)
240 I2C STOP CONDITION <–end first command
210 I2C START CONDITION <–begin second command
220 I2C WRITE: 0x9B GOT ACK: YES <–read address
230 I2C READ: 0x80 <– register value (10000000)
240 I2C STOP CONDITION <–end second command
I2C>

The register value, 10000000, now shows that the device is in standby (bit 7=1). Notice that bit 6 is now 0, no temperature data is available.

Clear bit 7 to exit standby, then wait for bit 6 to return to 1 before reading the temperature register.

I2C>{0x9a 1 0b00000000}
210 I2C START CONDITION
220 I2C WRITE: 0x9A GOT ACK: YES <–write address
220 I2C WRITE: 0x01 GOT ACK: YES<–select config register
220 I2C WRITE: 0x00 GOT ACK: YES<–value to write (00000000)
240 I2C STOP CONDITION
I2C>

Temperature data is ready when the configuration register value returns to 0x40 (01000000).

Temperature

The temperature register is read in two steps. First, a partial write command selects the temperature register (0), then a read sequence returns the contents.

I2C>{0x9a 0}{0x9b r}
210 I2C START CONDITION
220 I2C WRITE: 0x9A GOT ACK: YES <–write address
220 I2C WRITE: 0x00 GOT ACK: YES <–select temperature register
240 I2C STOP CONDITION
210 I2C START CONDITION
220 I2C WRITE: 0x9B GOT ACK: YES <–read address
230 I2C READ: 0x18 <–grab one byte
240 I2C STOP CONDITION
I2C>

The temperature is an integer value of degrees Celsius, negative numbers are represented as a twos complement. Positive values from 0 to 127 degrees Celsius are simply represented by that value. Negative temperatures have bit 7 set, and range from -1 to -65 (255-128), see table 4.4 on page 8 of the datasheet. The hexadecimal value 0x18 is equal to 24 in decimal, so the temperature reading is 24C (75F).

Like this post? Check out the parts posts you may have missed.

18 thoughts on “Parts: I2C Digital Thermometer (TC74)

  1. Cool! i can think of a lot of stuff to bolt this thing to.
    cpu heatsink, inside the freezer (because no one likes hard-as-a-rock ice cream!), my modded surround amp… thanx for the write up!

  2. It says “A 0.1uF capacitor (C1) decouples the chip from the power supply.” What does “decouples” mean in that sentence and why is the capacitor on the ground side and not the vcc side?

  3. > It says “A 0.1uF capacitor (C1) decouples the chip
    > from the power supply.” What does “decouples”
    > mean in that sentence and why is the capacitor on
    > the ground side and not the vcc side?

    Looks like C1 connects to both Pin 5, which is 3.3V and to GND. ‘Decouples’ means to basically provide some power protection against RF pickup – RF will go through the cap to ground, leaving the DC clean.

    An alternative word would be a ‘bypass’ capacitor, ref:
    http://en.wikipedia.org/wiki/Decoupling_capacitor

    I just placed a mouser order prior to seeing this neat little IC. I’ve put it on a list for next time…!

    Mike Yancey
    Dallas, Texas

  4. The component variety and quality of these posts is astounding. Short and sweet. I’m hoping to see some more complex devices requiring longer tutorials such as the DS28EA00 (1wire temp sensor with I/o pins) or perhaps one of the new Dallas RTC’s with 4Kbytes or more of NVRAM. What is already posted is pure gold.

  5. ds1621+ from maxim is a temp sensor with i2c interface and has better resolution than this one. Without much effort, you can easily get .5°C resolution from this ic. only downside i guess is the package

  6. is there any way of changing the address of the sensor? I would like to have more then one on a I2C bus. I can order small qualities of TC74 with address 9a but have to order 350 to get any of the other addresses.

  7. “is there any way of changing the address of the sensor? I would like to have more then one on a I2C bus.”
    Nope. Unfortunately not. I think this catches a lot of people out but I can buy them in single units thankfully :)

  8. From the TC74 Manual: ” Eight SMBus/I2C addresses are programmable for the TC74, which allows for a multi-sensor configuration. ” This suggests that the TC74 has eight programmable addresses. Like Jim said above, its near on impossible to get individually coded packages without ordering some serious numbers, so if you want multiple sensors on the same channel you need to program. I’ve scoured the internet for guides on how to program this chip, but there appears to be nothing out there. This is by far the most comprehensive guide but still to access to change the address.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.