Introduction: Raspberry Pi - TMP007 Infrared Thermopile Sensor Python Tutorial
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
LINK : https://www.controleverything.com/content/Temperature?sku=TMP007_I2CS#
3. I²C Cable
LINK : https://www.controleverything.com/content/I2C-Cables?sku=I2CAFF3
4. I²C Shield for Raspberry Pi
LINK : https://www.controleverything.com/content/I2C-Master?sku=TOUTPI2
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- ControlEverythingCommunity
Here is the link for the same :
The datasheet of TMP007 can be found here:
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.
# This code is designed to work with the TMP007_I2CS I2C Mini Module available from ControlEverything.com.
# 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)
# 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 * 256 + (data & 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.