Raspberry Pi - TMP007 Infrared Thermopile Sensor Python Tutorial
by Dcube Tech Ventures in Circuits > Electronics
3197 Views, 7 Favorites, 0 Comments
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.
What You Need..!!
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.
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
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.