Past exam question: Assignment 3, Q12
Open in the Padhaiko appHow do you interface TC74 temperature sensor using I2C?
Solution
TC74 Hardware & I²C Bus Connections: The TC74 is a digital serial temperature sensor ( to , resolution, signed 8-bit two's-complement output) communicating over the 2-wire I²C (TWI) bus. Its default 7-bit I²C address is 0x4D (for TC74A5; variants TC74A0–A7 range from 0x48 to 0x4F).
- SDA (Data): Connect TC74 pin 2 (
SDA) to ArduinoA4(PC4) with a pull-up resistor to+5 V(or ). - SCL (Clock): Connect TC74 pin 4 (
SCL) to ArduinoA5(PC5) with a pull-up resistor to+5 V. - Power: Connect
VDDto+5 V(or ) andGNDtoGND.
+5V
|
+------+------+
[4.7k] [4.7k] Pull-up resistors
| |
Arduino | | TC74 Sensor
+--------+ | | +-----------+
| A4(SDA)|--+-------------|------->| SDA |
| A5(SCL)|----------------+------->| SCL |
| +5V |------------------------>| VDD |
| GND |------------------------>| GND |
+--------+ +-----------+I²C Read Transaction Protocol for TC74: Using Arduino's Wire.h library, reading the temperature register (0x00) takes three steps:
- Write Register Pointer: Send the 7-bit slave address in write mode (
Wire.beginTransmission(0x4D)), write register address0x00(Temperature Register,Wire.write(0x00)), and terminate (Wire.endTransmission()). - Request 1 Byte (Read Mode): Send the slave address in read mode requesting 1 byte (
Wire.requestFrom(0x4D, 1)). - Read and Interpret: Verify
Wire.available()and read the signed 8-bit (int8_t) byte (Wire.read()), which directly gives the temperature in .
Arduino I²C Code (Wire.h):
#include <Wire.h>
const int TC74_ADDR = 0x4D; // Default 7-bit I2C address for TC74A5
void setup() {
Wire.begin(); // Join I2C bus as master
Serial.begin(9600);
}
void loop() {
// 1. Point to the TC74 Temperature Register (0x00)
Wire.beginTransmission(TC74_ADDR);
Wire.write(0x00);
Wire.endTransmission();
// 2. Request 1 byte (8-bit signed temperature in deg C)
Wire.requestFrom(TC74_ADDR, 1);
// 3. Confirm receipt and read byte
if (Wire.available()) {
int8_t tempC = (int8_t)Wire.read();
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println(" C");
}
delay(500);
}Interface the TC74 by wiring SDA to Arduino A4 and SCL to A5 (each with a pull-up to ), then use Wire.begin() to write register pointer 0x00 to the sensor's 7-bit I²C address (e.g., 0x4D), request 1 byte via Wire.requestFrom(0x4D, 1), and read the signed 8-bit temperature directly in .