Hi,
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 (http://www.mikroe.com/download/eng/...krobasic/pro/pic/help/i2c_library.htm#i2c1_rd).
I came across this thread : http://www.ccsinfo.com/forum/viewtopic.php?t=45147
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:
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.
Thanks
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 (http://www.mikroe.com/download/eng/...krobasic/pro/pic/help/i2c_library.htm#i2c1_rd).
I came across this thread : http://www.ccsinfo.com/forum/viewtopic.php?t=45147
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_Init(50000);
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)
IntToStr(DATA,y);
Glcd_Write_text(y,0,3,1 );
delay_ms(500);
IntToStr(DATA1,y);
Glcd_Write_text(y,0,4,1 );
delay_ms(500);
IntToStr(DATA2,y);
Glcd_Write_text(y,0,5,1 );
delay_ms(500);
Glcd_fill(0);
delay_ms(100);
}
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.
Thanks
Last edited: