Introduction: Raspberry Pi - TMP100 Temperature Sensor Python Tutorial

TMP100 High-Accuracy, Low-Power, Digital Temperature Sensor I2C MINI module. The TMP100 is ideal for extended temperature measurement. This device offers an accuracy of ±1°C without requiring calibration or external component signal conditioning. Here is the demonstration with a python code using Raspberry Pi.

Step 1: What You Need..!!

Picture of What You Need..!!

1. Raspberry Pi

2. TMP100

LINK : https://www.controleverything.com/content/Temperature?sku=TMP100_I2CS

3. I²C Cable

LINK : https://www.controleverything.com/content/I2C-Cabl...

4. I²C Shield for Raspberry Pi

LINK : https://www.controleverything.com/content/I2C-Mas...

5. Ethernet Cable

Step 2: Connection:

Picture of 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 TMP100 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:

Picture of Code:

The python code for TMP100 can be downloaded from our github repository- ControlEverythingCommunity

Here is the link for the same :

https://github.com/ControlEverythingCommunity/TMP1...

The datasheet of TMP100 can be found here:

https://s3.amazonaws.com/controleverything.media/c...

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.

# TMP100

# This code is designed to work with the TMP100_I2CS I2C Mini Module available from ControlEverything.com.

# https://www.controleverything.com/content/Tempera...

import smbus

import time

# Get I2C bus

bus = smbus.SMBus(1)

# TMP100 address, 0x4F(79)

# Select configuration register, 0x01(01)

# 0x60(96) Continuous conversion, comparator mode, 12-bit resolution

bus.write_byte_data(0x4F, 0x01, 0x60)

time.sleep(0.5)

# TMP100 address, 0x4F(79)

# Read data back from 0x00(00), 2 bytes

# temp MSB, temp LSB

data = bus.read_i2c_block_data(0x4F, 0x00, 2)

# Convert the data to 12-bits

temp = (data[0] * 256 + (data[1] & 0xF0)) / 16

if temp > 2047 :

temp -= 4096

cTemp = temp * 0.0625

fTemp = cTemp * 1.8 + 32

# Output data to screen

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

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

Step 4: Applications:

Various applications incorporating TMP100 low power, high accuracy digital temperature sensor include Power-Supply Temperature Monitoring, Computer Peripheral Thermal Protection, Battery Management as well as office machines.

Comments

About This Instructable

230views

0favorites

More by Dcube Tech Ventures:Home Automation with Raspberry Pi using Relay boardMotion Control with Raspberry Pi and LIS3DHTR, 3-Axis Accelerometer, using Python3-Axis Accelerometer, ADXL345 with Raspberry Pi using Python
Add instructable to: