I2c communication for sensor and serial apis

I want to read temperature from TMP006 and send data to terminal using bluetooth. I am able to read temperature without any problem, and I can also send random character or string using bluetooth. But when I try to combine these features, there is no output. From my understanding the problem is when I define TMP006. Following is my code. Can somebody please point out where I’m making mistake. Thank you in advance.

#include “mbed.h”
#include “TMP006.h”

#define Address 0x80
Serial rn41(p9,p10); //name the serial port rn41
TMP006 sensor(p12, p13, Address);

int main() {
rn41.baud(115200); // set baud for RN41
while (1) {

    rn41.printf("Test");
    rn41.printf("Temperature: %f \r \n", sensor.readObjTempC(Address));
    wait(1.0);
}

}

Hello,

What a target board do you use?
You wrote, it is working separately but not together. That seems like a collision between both data buses.

BR, Jan

Hi Jan, I’m using LPC1768 as the embedded system and a regular plain application board(no name). What do you suggest in case of data bus collision?
Thank you

Also for what it’s worth. The hardware isn’t causing the collision. If I commented out the //TMP006 sensor(…) part and the subsequent codes involving TMP006, then the program works fine being able to use bluetooth and all.

The LPC1768 has:

  • I2C on pins p9-10 and on pins p27-28
  • Serial pins are on same pins like I2C above and also on pins P13-14

In you constructor I see

Serial rn41(p9,p10); //name the serial port rn41
TMP006 sensor(p12, p13, Address);

If I understand it correctly the TMP006 use SMBUS which is I2C.
Are you sure your pins of the sensor object are correct?

The idea about collision was about, when you use 2 interfaces what are shared on multiple pins what you use for different tasks, can lead to problems… Maybe I am wrong.

BR, Jan

You are absolutely correct. I had just gotten it work using pin 28 and 27 and I saw this notification. It’s working perfectly now. Thank you for your time and help Jan. Have a great day.