Page 1 of 1

Programming Temperature Sensor in I2C

Posted: Mon Apr 13, 2015 12:26 am
by airforcejeesh
I am trying to program an ADT7410, a 16-bit temperature sensor, on a PIC16F887. Unfortnatly, the datasheet is vague to me and I haven't found any good guides our libraries.

(Datasheet: http://www.analog.com/media/en/technica ... DT7410.pdf)

I am pretty sure the first set of I2C instructions that I write are 0x48, 0x00, and 0x03, but I don't know what 'read' addresses to send after that. Any help would be greatly appriciated.


FWIW, I also know that eventually I will have to use math to convert the measure into degrees Celsius. I'm sure I can figure that part on my own.

Re: Programming Temperature Sensor in I2C

Posted: Fri Apr 24, 2015 3:59 pm
by airforcejeesh
Any help would be much appreciated.

Re: Programming Temperature Sensor in I2C

Posted: Fri Apr 24, 2015 4:11 pm
by LeighM
Hi,

The device address is 7 bits, bit 0 is used to signal read or write.
To read the temperature looks like you will need to send...

Start, 0x90, 0x00, Restart, 0x91, (read) MSByte, LSByte, Stop

Leigh

Re: Programming Temperature Sensor in I2C

Posted: Fri Apr 24, 2015 4:45 pm
by airforcejeesh
Thank you for responding.

I'm with you so far, but how do I get the two read bytes (MSB & LSB) to equal one variable (my temperature)?

Also, how did you learn that the address was 0x90? I don't see it in the datasheet.

Re: Programming Temperature Sensor in I2C

Posted: Mon Apr 27, 2015 8:29 am
by LeighM
Hi
All I2C device addresses are 7 bits, MSB first, with the LSB followed by bit 0 which is the read or write flag.
See the protocol description on page 17
There is also an SDA/SCL waveform diagram in Fig 15 on page 18 that shows how the address frame is constructed.
So you send bytes, where the frame 1 byte is 0x90 (which is address 0x48 shifted one bit left, and bit 0 set to 0 for write)

Similarly, you need to do bit shifting to get your single variable result from MSB and LSB

Code: Select all

Temperature = (MSB << 8) OR LSB