Introduction: Raspberry Pi - TMP007 Infrared Thermopile 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.

TMP007 is an infrared thermopile sensor which measures the temperature of an object without being in contact with it. The infrared energy emitted by the object in the sensor field is absorbed by the thermopile integrated in the sensor. The thermopile voltage is digitised and fed as an input to the integrated math engine. This integrated math engine calculates the object temperature. Here is its working demonstration with Raspberry Pi using python code.

Step 1: What You Need..!!

1. Raspberry Pi

2. TMP007

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 TMP007 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 TMP007 can be downloaded from our GitHub repository- DCUBE Store Community.

Here is the link.

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

https://pypi.python.org/pypi/smbus-cffi/0.5.1

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.

# TMP007

# This code is designed to work with the TMP007_I2CS I2C Mini Module available in DCUBE Store.

import smbus

import time

# Get I2C bus

bus = smbus.SMBus(1)

# TMP007 address, 0x40(64)

# Select configuration register, 0x02(02)

# 0x1540(5440) Continuous Conversion mode, Comparator mode

data = [0x1540]bus.write_i2c_block_data(0x40, 0x02, data)

time.sleep(0.5)

# TMP007 address, 0x40(64)

# Read data back from 0x03(03), 2 bytes

# cTemp MSB, cTemp LSB

data = bus.read_i2c_block_data(0x40, 0x03, 2)

# Convert the data to 14-bits

cTemp = ((data[0] * 256 + (data[1] & 0xFC)) / 4)

if cTemp > 8191 :

cTemp -= 16384

cTemp = cTemp * 0.03125

fTemp = cTemp * 1.8 + 32

# Output data to screen

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

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

Step 4: Applications:

TMP007 finds its application in the systems where non-contact temperature measurement is required. They are employed in laptop and tablet cases, batteries etc. They are also incorporated in heat sinks as well as laser printers. Its higher efficiency in measuring the temperature without being in contact with the actual object gives it an extra edge for its various applications.