cancel
Showing results for 
Search instead for 
Did you mean: 

Reading LIS2DE12 temperature always reads 0

WSpar.1
Associate III

Hi all,

I'm currently not able to read the temperature of my lis2de12.
It always returns zero.

 

lis2de12_temperature_meas_set(&dev_ctx, LIS2DE12_TEMP_ENABLE);

lis2de12_data_rate_set(&dev_ctx, LIS2DE12_ODR_400Hz );

lis2de12_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);

 

What could be the issue here?
I'm only reading temp, not X Y Z values yet.

TEK00003.PNG

 

UPDATE:

After playing around reading OUT_TEMP_L (0Ch), OUT_TEMP_H (0Dh) separately, my code now reads twice 0x80.

I think my platform functions are not incrementing the register address?

static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)

{

HAL_I2C_Mem_Read(handle, LIS2DE12_I2C_ADD_H, reg, 1, (uint8_t*)bufp, len, 1000);

 

return 0;

}

 

Otherwise I would assume seeing 0x0D in the scope image.

 

 

3 REPLIES 3
Federica Bossi
ST Employee

Hi @WSpar.1 ,

Please, look at our drivers on github where you can find how to implement the reading of the temperature.

Let me know if this helps.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

I'm using that driver, it works fine for reading single register, not if you need incremental register address 0x0C to 0x0D

The working depends on what is inside platform_read()

For now I fixed it with, but not ideal:

static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)

{

 

if(len == 2)

{

HAL_I2C_Mem_Read(handle, LIS2DE12_I2C_ADD_H, reg, 1, (uint8_t*)bufp, 1, 1500);

reg++;

bufp++;

 

HAL_I2C_Mem_Read(handle, LIS2DE12_I2C_ADD_H, reg, 1, (uint8_t*)bufp, 1, 1500);

} else {

 

HAL_I2C_Mem_Read(handle, LIS2DE12_I2C_ADD_H, reg, 1, (uint8_t*)bufp, len, 1500);

}

 

return 0;

}

 

Would be nice if HAL_I2C_Mem_Read() had an register increment option

 

 

Federica Bossi
ST Employee

Hi @WSpar.1 ,

You can look here how to implement the read/write multiple.

You will find this comment:  /* Read multiple command */ and how to implement it in I2C communication.

Hope this helps.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.