i2c Temperature example code

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone have example gcc code for working with temperature sensors via i2c?

Specifically I'm working with a TMP75AIDR (http://focus.ti.com/lit/ds/symli...) and an ATMEGA32 (http://www.atmel.com/dyn/resourc...)

However, any gcc code for any other i2c sensor and/or avr would be very welcomed.

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lots of hits using something called "google"

Take a look at Jesper's page.

http://www.myplace.nu/avr/thermo...

I'm building his miniDDS right now (but with a Mega32)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

how do you use this "google"?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

jasonphd wrote:
how do you use this "google"?

Is that a joke? Or do you really not know about www.google.com ? (sticking my neck out here but as far as I know this IS the most popular page on the internet - by miles)

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It was a joke.

I still need an example of i2c code that works with winavr and i2c temperature sensors.

The link above did not function in winavr.

I've been at this for days and tried many different samples found on that "google" thing with no luck. Any help would be greatly appreciated!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Every temperature sensor will have a different I2C interface - you can't just run sample code and expect it to work. You will need to do the work to interface with this particular sensor yourself. All you need to do is find a suitable I2C library and implement the protocol defined in the PDF for your component.

The protocol is quite simple. You either send the address for the register to change followed by the value to set it to or send the address then initiate a read request to get the value. You need to configure it (if required), point to the temperature register then just keep reading from it. It starts with sensible defaults and points at the temperature register.

An example for an imaginary library:

char temperature;

i2c_init();

while(1) {
  ...
  i2c_read(0b1001000, 1, &temperature);
  ...
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found some sample code, but for some reason it hangs when trying to initialize the i2c.

i'm trying to access an i2c temperature sensor (http://focus.ti.com/lit/ds/symli...) using an atmega32 (http://www.atmel.com/dyn/resourc...) using this winavr code: http://www.sqlpaste.com/?44411 ... however, after calling i2c_init(), my app hangs.... can anyone give me any tips that might help me?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

jasonphd wrote:
It was a joke.

I still need an example of i2c code that works with winavr and i2c temperature sensors.

The link above did not function in winavr.

I've been at this for days and tried many different samples found on that "google" thing with no luck. Any help would be greatly appreciated!

I'm quite sure that you can go to most any semiconductor manufacturer (TI, Maxim, Motorola, National Semiconductor, etc...) and look at tons of application notes specfically aimed at I2C and have all of the code examples you want.

In fact, I do believe that Atmel even has application notes on their web-site aimed at I2C.

And you provide a link to the manufacturer of the particular I2C device that you are attempting to interface to the Mega32. I just can't believe that the manufacturer doesn't have code examples in the datasheet or application notes relating specifically to this particular device.

Oh! By the way... What is Google???

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston