Interfacing IR temperature Sensor (MLX 90615) with PIC

Thread Starter


Joined Dec 27, 2010

I am trying to read temperature from MLX90615ssg-daa infra red temperature sensor using PIC18F4550. The Sensor uses SMBus, and I am using the I2C library of the mikroC compiler (

I came across this thread :
where a similar question was asked. I tried to use the same code, but it did not work.

This is the code I have written:
Rich (BB code):
     while (1)

     I2C1_Start();                 // Issue start signal
     I2C1_Wr(0xB6);             // Write Address
     I2C1_Wr(0x07);              // address of  To Register 
     I2C1_Repeated_Start();               // Issue repeated start signal
     I2C1_Wr(0xB7);             // Read Address  
     DATA = I2C1_Rd(1);     //Read first byte (device Address)
     DATA1 = I2C1_Rd(1);   //
     DATA2 = I2C1_Rd(0);   //PCE Byte (You need to _NACK_ the last byte)
     Glcd_Write_text(y,0,3,1 );
     Glcd_Write_text(y,0,4,1 );
     Glcd_Write_text(y,0,5,1 );
Nothing is displayed on the screen, which indicates that there is no communication between the two devices.

The problem is not from the display code, because I have tested it and it is working.

I connected the sensor as suggested in the data sheet (available here).

The PIC is powered using 5v, then I use a voltage divider to get 3.3v which powers the IR sensor. The SDA and SCL are connected through a bidirectional voltage translator (using mosfet and 2 resistors).

I would really appreciate it if someone can help me figuring out what is wrong.

Last edited:

Thread Starter


Joined Dec 27, 2010

I changed the voltage divider to 3 diodes in series to get 3.3v which powers the sensor. I also found that one of the MOSFETs (logic translator) is not working properly.

I fixed those problems, and I can see the values on the GLCD.

The problem is that I don't understand what these values are. I only want the temperature.
The values I get are:
183 ==> result of first read = 0xB7 which is the read address
170 ==> result of second read
111 ==> result of third read

I also added this line to the code after initializing the I2C.

SSPSTAT.CKE=1; // Enable SMBus specific inputs

The problem is that I don't understand what these values represent. It seems that non of them represent the temperature, because I tried to place hot and cold objects above the sensor but non of the values changed.
I can't think of any solution. I thinks it is most likely that the sensor is damaged (although it is new).
What do you think guys ?
Last edited:


Joined Apr 24, 2011
I used this device (or a similar one) a few years ago. The hard part was computing the "Packet Error Code" byte which is a CRC-8 check sum. If this check sum is not correct for the data you are sending the transmission is ignored. That makes any set-up instructions hard to do.

Sorry I no longer have access to that work.