Arduino code for tmp102

Your source for all things Atmel.

Moderator: phalanx

Arduino code for tmp102

Postby pjrestrepo » Sat Mar 27, 2010 4:53 pm

This sample code shows how to use the Digital Temperature Sensor Breakout - TMP102. Also notice that I am using a 5 v Arduino decimilanove. To drive the 3.3v TMP102 breakout, I am using Sparkfun's Logic Level Converter (sku: BOB-08745), connected as follows:

Low voltage to the 3.3v pin of the Arduino
High voltage to the 5.0v pin
High voltage Channel 1 Txo to the SDA pin (analog 4)
High voltage Channel 2 Txo to the SCL pin (analog 5)
Low voltage Channel 1 Txi to the SDA pin of tmp102
Low voltage Channel 2 Txi to the SCL pin of tmp102
The RX pins of the logic converter are not used
V+ of tmp102 connected to 3.3v
ADD0 of tmp102 connected to ground
ALT of tmp102 not connected
All grounds connected together.

The code is attached. It puts out the temperature in Deg C to a serial monitor.
Attachments
tmp102.zip
Small code showing how to use the tmp102 sensor
(400 Bytes) Downloaded 524 times
Last edited by pjrestrepo on Fri Jun 04, 2010 7:57 pm, edited 1 time in total.
pjrestrepo
 
Posts: 3
Joined: Sat Mar 27, 2010 4:34 pm

Re: Arduino code for tmp102

Postby csete » Fri Jun 04, 2010 3:50 pm

Thanks for posting this, it was very helpful.
Wouldn't it be safer to connect V+ of tmp102 to 3.3V instead of 5?
csete
 
Posts: 1
Joined: Fri Jun 04, 2010 3:43 pm
Location: Copenhagen, Denmark

Re: Arduino code for tmp102

Postby pjrestrepo » Fri Jun 04, 2010 7:57 pm

Ooops, you are correct. V+ of the tmp102 should be connected to the 3.3V pin (low voltage side of the logic level converter). I corrected my previous post.
pjrestrepo
 
Posts: 3
Joined: Sat Mar 27, 2010 4:34 pm

Re: Arduino code for tmp102

Postby dargs » Mon Sep 13, 2010 2:26 am

Hi, quick question, if I connect the TMP102 V+ to the arduino onboard 3.3v, do I need to level shift the SDA & SLC signals, or can I connect them directly to Analog4/5 on the Arduino?

In the comments section of the product page (http://www.sparkfun.com/commerce/produc ... ts_id=9418) You(?) have said:

"I have an Arduino duemilanove, and have the tmp102 working. I connected V+ to the 3.3v pin on the Arduino board. Ground and Add0 to ground. SCL to analog pin 5, and sda to analog pin 4. The Alt connection is not needed. Here is my code, to read the sensor and print it through the serial port. I hope it helps. "

I am also aiming to connect an RTC module (BOB-00099) on the same I2C bus, which is running ok at the moment. So not sure if it's all going to work.. (First time playing with I2C)...


cheers
dargs
dargs
 
Posts: 2
Joined: Sat Dec 05, 2009 5:13 am

Re: Arduino code for tmp102

Postby pjrestrepo » Mon Sep 13, 2010 2:28 pm

I am not sure whether the +5 voltage on the Arduino will be too much for the tmp sensor. That's why I went the safe rout. I am also connecting the same RTC, but haven't had the time to complete my project. The first RTC I got from Sparkfun was dead on arrival, and I got a replacement sometime later. But I got busy afterwards and have not been able to test the whole project together. Let me know what you decide to do, and how it goes.

My project is a wireless thermostat that can start the AC or Heating and move a damper in the basement that moves the air mostly to the second floor. That way, I don't have to cool or heat the whole house in the evening and night.
pjrestrepo
 
Posts: 3
Joined: Sat Mar 27, 2010 4:34 pm


Return to Code

Who is online

Users browsing this forum: Bing [Bot] and 3 guests