TMP102

21 Jan 2012

I'm using a couple of TMP102 temperature sensors in a project (using IC2 pins 27 & 28). I've noticed that if the temperature sensors are not present then the program halts. I'm trying to find away to prevent this from happening so that I can still use other aspects of the program in the event of a sensor failure. I was also hoping to set up one version of my program but be able to use it with either one or two temp sensors without changing the code.

Anyone know if this is possible? Can I do any kind of error capture in the event that the sensors fail or are not present?

Thanks.

21 Jan 2012

Hi Leo,

Assuming the bus is functional, then you can certainly detect if a device is present. Take a look at:

This searches the bus for connected devices, so it should be obvious how you'd check if a specific device is present.

Hope that works; please say if not, otherwise it'd be great to share your working solution!

Simon

21 Jan 2012

You can check for presence of the sensors as mentioned by Simon. However, make sure that you always have the 2 pull-up resistors present on the i2c bus. When they are missing the bus hardware (and software) will hang.

Wim

22 Jan 2012

information about the pullups is here :-

http://mbed.org/handbook/I2C

I've then done a version of TMP102 that includes the code linked above

http://mbed.org/users/simon/programs/I2CU/

with that combination, if the sensor is missing/broken then the pullups allow the code to detect that, if the sensor is attached and working then the code can detect that and then read the value safely