Skip to main content
Graduate
February 3, 2024
Question

Reading LIS2DE12 temperature always reads 0

  • February 3, 2024
  • 2 replies
  • 1089 views

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.

 

 

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    February 5, 2024

    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.

    WSpar.1Author
    Graduate
    February 5, 2024

    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

     

     

    Technical Moderator
    March 4, 2024

    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.