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.
Programming Temperature Sensor in I2C
Moderator: Benj
-
- Flowcode v5 User
- Posts: 11
- Joined: Tue Dec 30, 2014 10:03 pm
- Has thanked: 5 times
- Contact:
-
- Flowcode v5 User
- Posts: 11
- Joined: Tue Dec 30, 2014 10:03 pm
- Has thanked: 5 times
- Contact:
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Programming Temperature Sensor in I2C
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
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
-
- Flowcode v5 User
- Posts: 11
- Joined: Tue Dec 30, 2014 10:03 pm
- Has thanked: 5 times
- Contact:
Re: Programming Temperature Sensor in I2C
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.
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.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Programming Temperature Sensor in I2C
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
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