Introduction: Raspberry Pi - TCN75A Temperature Sensor Python Tutorial

About: We are a group of makers. We work in IoT, IOS app, android app, embedded design, sensor design, raspberry pi, arduino, beaglebone, particle electron, particle photon, Bluetooth.

TCN75A is a two-wire serial temperature sensor incorporated with temperature-to-digital converter. It is incorporated with user programmable registers that provide flexibility for temperature-sensing applications. The register settings allow users to configure power saving mode, shutdown mode, one shot mode etc.The sensor has an i2c compatible serial interface which can facilitate connection of upto eight devices in a single serial bus. Here is its demonstration with raspberry pi using python code.

Step 1: What You Need..!!

1. Raspberry Pi

2. TCN75A

3. I²C Cable

4. I²C Shield for Raspberry Pi

5. Ethernet Cable

Step 2: Connection:

Take a I2C shield for raspberry pi and gently push it over the gpio pins of raspberry pi.

Then connect the one end of I2C cable to TCN75A sensor and the other end to the I2C shield.

Also connect the Ethernet cable to the pi or you can use a WiFi module.

Connections are shown in the picture above.

Step 3: Code:

The python code for TCN75A can be downloaded from our github repository-DCUBE Store.

Here is the link for the same :

We have used SMBus library for python code, the steps to install SMBus on raspberry pi is described here:

You can also copy the code from here, it is given as follows:

# Distributed with a free-will license.

# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

# TCN75A

# This code is designed to work with the TCN75A_I2CS I2C Mini Module .

import smbus

import time

# Get I2C bus

bus = smbus.SMBus(1)

# TCN75A address, 0x48(72)

# Select configuration register, 0x01(01)

# 0x60(96) 12-bit ADC resolution

bus.write_byte_data(0x48, 0x01, 0x60)


# TCN75A address, 0x48(72)

# Read data back from 0x00(00), 2 bytes

# temp MSB, temp LSB

data = bus.read_i2c_block_data(0x48, 0x00, 2)

# Convert the data to 12-bits

temp = ((data[0] * 256) + (data[1] & 0xF0)) / 16

if temp > 2047 :

temp -= 4096

cTemp = temp * 0.0625

fTemp = (cTemp * 1.8) + 32

# Output data to screen

print "Temperature in Celsius : %.2f C" %cTemp

print "Temperature in Fahrenheit : %.2f F" %fTemp

Step 4: Applications:

TCN75A is a temperature sensor that can be employed in personal computers and servers.It can also be deployed in entertainment systems,office equipments, hars disk drives and other PC peripherals.This sensor also find its application in data communication equipment.