Skip to main content
Visitor II
February 5, 2018
Question

LPS22HB is returning zero as the sensor output

  • February 5, 2018
  • 1 reply
  • 1021 views
Posted on February 05, 2018 at 23:46

After initializing an SPI 3-wire interface with a STM32L4 MCU on a custom board, the driver always returns zero as the pressure value whenever the get pressure method is called. Even the temperature sensor reading is also returning zero as output. Is this an initialization error or calibration error?

#stm32l4-spi #lps22hb
    This topic has been closed for replies.

    1 reply

    February 6, 2018
    Posted on February 06, 2018 at 08:40

    Hello,

    Do you have a logic analyzer to verify you send the data to the sensor and get the data back correctly?

    Have you started the measurement in the sensor?

    Could you share your code?

    David

    Visitor II
    February 6, 2018
    Posted on February 06, 2018 at 15:47

    Hi David,

    I don't have a logic analyzer to verify the data. I ported the code from en.x-cube-mems1 expansion package. The sensor is initialized in the 3-wire SPI mode. The pseudo code for initialization and sensor measurement is below

    BSP_PRESSURE_Init( PRESSURE_SENSORS_AUTO, &PRESSURE_handle );

    BSP_PRESSURE_Sensor_Enable(PRESSURE_handle);

    if(BSP_PRESSURE_IsEnabled(PRESSURE_handle, &status) == COMPONENT_OK && status == 1)

    {

     BSP_PRESSURE_Get_Press(PRESSURE_handle, &PRESSURE_Value);

    }

    ST Employee
    February 6, 2018
    Posted on February 06, 2018 at 20:54

    I suppose the problem is in the SPI 3-wire settings of you microcontroller not in the sensor, it can be tricky and difficult to debug witnout scope or logic analyzer.

    I would recomend you to double check your SPI configuration or rather use I2C at firts.