11 years, 8 months ago.

how come i get 0degree temperature when i (i think correctly) adress my TMP102

Hi, I cannot read anything from the TMP102, i tried with the example code and this gave nothing. I made my own code:

#include "mbed.h"

Serial pc (USBTX, USBRX);

I2C i2c (p9, p10);  

const int addr = 0x90; 


int main() {

char send[1];

send[0]=0;   //sending the pointer adres to temperature register

char ontvangentemp[2];  //want 2 bytes of information in

while(1){

i2c.write(addr, send, 1, 0);

i2c.read(addr, ontvangentemp, 2, 0);  

pc.printf("test voor TMP102_nieuw1\n\r");

pc.printf("\n\r the temperatuur is %d , %d", ontvangentemp[0], ontvangentemp[1]);

} 

}

The first time i got "test .... the temperatuur is 0, 128), the next times i always get 0,0. how come? i know this will not be the right temperature because i still have to do some conversion Next problem is, most of the time when i push on the button nothing happens in hyperterminal, and then suddenly they come with 10 at the time and i dont see a relation when it happens. anybody has an idea, thanks in advance

1 Answer

11 years, 8 months ago.

Have you tried the TMP102 library? You can find a link to it and an example of its use on the cookbook page TMP102 Temperature Sensor.

Accepted Answer