Home » Raspberry Pi and TMP006 Infrared Thermopile Sensor python example

Raspberry Pi and TMP006 Infrared Thermopile Sensor python example

by shedboy71

In this article we look at a temperature sensor – this time its the TMP006 and we will connect it to our Raspberry Pi and show how to get readings from it in python

This is the sensor that I will be using

Lets look at some information regarding the sensor

Texas Instruments’ TMP006 is the first in a series of temperature sensors that measure the temperature of an object without the need to make contact with the object.

This sensor uses a thermopile to absorb the infrared energy emitted from the object being measured and uses the corresponding change in thermopile voltage to determine the object temperature.

Infrared sensor voltage range is specified from -40°C to +125°C to enable use in a wide range of applications. Low power consumption along with low operating voltage makes the part suitable for battery-powered applications.

The low package height of the chip-scale format enables standard high volume assembly methods, and can be useful where limited spacing to the object being measured is available.

Features

Complete single-chip digital solution, including integrated MEMS thermopile sensor, signal conditioning, ADC and local temperature reference

Digital output:
Sensor voltage: 7 µV/°C
Local temperature: -40°C to +125°C
SMBus™ compatible interface
Pin-programmable interface addressing
Low supply current: 240 µA
Low minimum supply voltage: 2.2 V

Parts Required

 

Name Link
Raspberry Pi Raspberry Pi 4 Model B Development Board
TMP006 TMP006 Contact-less IR Thermopile Sensor Sensor Module
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

pi and tmp006

pi and tmp006

 

Code Example

This uses a library from Adafruit which you can install like this from the terminal

  • sudo pip3 install adafruit-circuitpython-tmp006

I then opened the Mu editor and entered the following code example, which is the same as the default example

[codesyntax lang=”python”]

import time
import board
import busio
import adafruit_tmp006
 
# Define a function to convert celsius to fahrenheit.
def c_to_f(c):
    return c * 9.0 / 5.0 + 32.0
 
 
# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_tmp006.TMP006(i2c)
 
# Initialize communication with the sensor, using the default 16 samples per conversion.
# This is the best accuracy but a little slower at reacting to changes.
# The first sample will be meaningless
while True:
    obj_temp = sensor.temperature
    print(
        "Object temperature: {0:0.3F}*C / {1:0.3F}*F".format(obj_temp, c_to_f(obj_temp))
    )
    time.sleep(5.0)

[/codesyntax]

Output

Run this example and you should see the following

Object temperature: 27.956*C / 82.322*F
Object temperature: 29.212*C / 84.582*F
Object temperature: 30.822*C / 87.479*F
Object temperature: 27.267*C / 81.081*F
Object temperature: 17.911*C / 64.240*F

You can see the difference in the object temperature readings when it was pointing at my hand

Links

 

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More