element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Temperature sensing with the Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fustini
  • Date Created: 26 Jul 2012 6:26 AM Date Created
  • Views 3390 views
  • Likes 2 likes
  • Comments 11 comments
Related
Recommended
  • i2c
  • rpiintermediate
  • raspberry_pi
  • raspberrypi
  • rpi

Temperature sensing with the Raspberry Pi

fustini
fustini
26 Jul 2012
imageWant to build this project?
View Parts

 

In my previous post, I showed how to add a real-time clock (RTC) to Raspberry Pi via the I2C bus.  Another device that is simple to interface with the Raspberry Pi via the I2C bus is the TMP102 temperature sensor.  Technically, its datasheet states "Two-Wire Interface", but TWI can be treated as synonymous with I2C in this context.  For convenience, I bought SparkFun's TMP102 breakout board:

image

Unlike with the DS1307 RTC in my previous post, this device can run at 3.3V so no logic level converter is needed.  I was able to add the TMP102 to my existing broadboard configuration with the RTC.  I simply added to the SDA and SCL lines on the 3.3V side of the logic level converter that is used for the DS1307 RTC:

image

(From Left to Right: Adafruit 4-channel I2C-safe logic level converter, Adafruit DS1307 RTC board, TMP102 temperature senor, SparkFun logic level converter board [connected to FTDI cable for serial console])

image

(same order as captioned above)

 

As I described in the RTC post, I am using Chris Boot's Wheezy image which features the Linux 3.2 kernel and a proper I2C driver (UPDATE: Adafruit's Occidentalis v0.2 now supports the tmp102, too).  Chris demonstrates in his I2C and the Raspberry Pi post how to setup and read from the temperature sensor:

 

# echo tmp102 0x48 > /sys/class/i2c-adapter/i2c-0/new_device

# sensors

tmp102-i2c-0-48

Adapter: bcm2708_i2c.0

temp1:        +21.6°C  (high = +160.0°C, hyst = +150.0°C)

Screenshot of sensors on the Pi:

image

And finally I decided to replace the jumper wires connecting the breadboard and the Pi with the Adafruit Pi Cobbler:

image

 

Cheers,

Drew

http://twitter.com/pdp7

 

 

 

Product Name*DescriptionSupplier
Raspberry Pi Model B Raspberry Pi model BRaspberry Pi
Buy Now
Optical mouse Basic USB optical mouseIONE / Pro Signal
Buy Now
Raspberry Pi power supply 120-240v to 5V power supply with micro USB connectorRaspberry Pi
Buy Now
Keyboard Basic USB keyboardGear Head / A4 Tech
Buy Now
Pre-programmed 4GB SD card 4GB Class 4 SD card preloaded with Debian 6 LinuxSamsung
Buy Now
Adafruit Pi Cobbler GPIO breakout kit for Raspberry PiAdafruit Industries
Buy Now
Breadboard Basic breadboard with 830 connection pointsTwin Industries
Buy Now
Jumper wire bundle Jumper wires for use on breadboardBud Industries
Buy Now
TI TMP102 breakoutTI TMP102 I2C temperature sensor on breakout boardTI / Sparkfun electronics

 

*Products and resources listed are listed to help members build their own Pi Projects. They are suggestions and listed for educational purposes. For substitutions of any parts, please post a question asking the original author.

  • Sign in to reply

Top Comments

  • morgaine
    morgaine over 13 years ago +1
    The I2C bandwagon picks up speed. I have a little I2C project in the works too, details if it ever surfaces. In case people were wondering where it came from, the " sensors " command is one of the utilities…
  • Former Member
    Former Member over 12 years ago +1
    Example with two TMP102 sensors:
  • Former Member
    Former Member over 12 years ago

    Example with two TMP102 sensors:

    image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 13 years ago in reply to Former Member

    Definately not a stupid question.  For this TMP102 sensor, you can have multiple units on the same I2C bus.  You just have to configure them to use different I2C addresses.  Check out: https://www.sparkfun.com/products/9418

     

    Another option is to use a seperate ADC along which could handle several analog temp sensors.  Checkout this Adafruit tutorial: http://learn.adafruit.com/send-raspberry-pi-data-to-cosm

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 13 years ago

    Really cool. I'm quite new to this kind of stuff so my question might be stupid, but is it possible (or hard) to connect multiple temperature sensors to the RPi?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 13 years ago

    fyi - the Adafruit Occidentalis v0.2 image now supports the tmp102:

    root@raspberrypi:~# modprobe tmp102

    root@raspberrypi:~# lsmod

    Module Size Used by

    tmp102 3558 0

    hwmon 1977 1 tmp102

    rtc_ds1307 7602 0

    i2c_dev 6423 0

    snd_bcm2835 21781 0

    snd_pcm 87261 1 snd_bcm2835

    snd_seq 67042 0

    snd_timer 21734 2 snd_seq,snd_pcm

    snd_seq_device 6928 1 snd_seq

    snd 61480 5 snd_seq_device,snd_timer,snd_seq,snd_pcm,snd_bcm2835

    snd_page_alloc 5411 1 snd_pcm

    spidev 5600 0

    evdev 9780 0

    spi_bcm2708 5386 0

    rpi_pwm 7203 0

    i2c_bcm2708 3834 0

    root@raspberrypi:~# echo tmp102 0x48 > /sys/class/i2c-adapter/i2c-0/new_device

    root@raspberrypi:~# sensors

    tmp102-i2c-0-48

    Adapter: bcm2708_i2c.0

    temp1: +26.6°C (high = +160.0°C, hyst = +150.0°C)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 13 years ago in reply to Former Member

    Ah, ok.  There's a couple other easy options for the Pi, too.   I've also used the DS18B20 which is a 1-wire digital temp sensor (see my post Raspberry Pi speaks 1-wire with Adafruit's Occidentalis image).  This TMP102 module was $6 whereas the DS18B20 you can find for around $4.

     

    The third option is an analog temp sensor like the TMP36TMP36 which is less than $2 along with an external ADC like the MCP3008MCP3008 which is about $2 and could read 8 different sensors.  Adafruit has a great tutorial on using the MCP3008 and TMP36.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube