cancel
Showing results for 
Search instead for 
Did you mean: 

I2C can n't read the Temperature

Bont_17 Gtm
Associate II
Posted on August 02, 2017 at 13:24

 stm32f302 Controller interfacing to Temperature sensor Mlx9061. The temperature sensor does not read the data.

Here is my Code , can you help me guys?

I2C Address for Mlx90614 0x054   Memory Address is 0x07

unsigned char buffer[5];

void mlx90614_sensor(void)

{

 //HAL_I2C_Master_Transmit(&hi2c2,0x54<<1,buffer,3,100);

 HAL_I2C_Mem_Write(&hi2c2, 0x54, 0x07, 8, buffer, 1, 100);

 //HAL_Delay(10);

 HAL_I2C_Mem_Read(&hi2c2, 0x54, 0x07, 8, buffer, 1, 100);

       HAL_Delay(10);

}

2 REPLIES 2
Posted on August 02, 2017 at 14:17

Hello!

First of all this sensor is SMBus  compatible(different voltages)

HAL_I2C_Mem_Write(&hi2c2, 0x54, 0x07, 8, buffer, 1, 100);

By calling this function, you mean that the address 0x07 has 8 bytes long address. not correct.

Device address must be shifted left by one.

0690X00000607q3QAA.png

So making the function like this is more compliant(but not) to the datasheet

HAL_I2C_Mem_Write(&hi2c2, 0x54<<1, 0x00, 1, buffer, 6, 1000);

Means that at device's address shifted by one left and at memory location 0x00 (which address is one byte long) ,write six bytes contained in buffer with one second timeout!

Thesse six bytes must prepared accordingly to the datasheet