Introduction: Raspberry Pi - TMP007 Infrared Thermopile Sensor Java 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 java 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: Connections:

Take an 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 java code for TMP007 can be downloaded from our github repository- Dcube Store Community

Here is the link for the same :

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

http://pi4j.com/install.html

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

import com.pi4j.io.i2c.I2CBus;

import com.pi4j.io.i2c.I2CDevice;

import com.pi4j.io.i2c.I2CFactory;

import java.io.IOException;

public class TMP007

{

public static void main(String args[]) throws Exception

{

// Create I2CBus

I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);

// Get I2C device, TMP007 I2C address is 0x41(64)

I2CDevice device = bus.getDevice(0x41);

// Select configuration register

// Continuous conversion, comparator mode

byte[] config = {0x15, 0x40};

device.write(0x02, config, 0, 2);

// Read 2 bytes of data from address 0x03(3)

// temp msb, temp lsb

byte[] data = new byte[2];

device.read(0x03, data, 0, 2);

// Convert the data to 14-bits

int temp = (((data[0] & 0xFF) * 256 + (data[1] & 0xFC)) / 4);

if(temp > 8191)

{

temp -= 16384;

}

double cTemp = temp * 0.03125;

double fTemp = cTemp * 1.8 + 32;

// Output data to screen

System.out.printf("Temperature in Celsius : %.2f C %n", cTemp);

System.out.printf("Temperature in Fahrenheit : %.2f C %n", 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.