Skip to main content
Visitor II
September 7, 2020
Question

STM32L496ZG +MPL3115A2 interface

  • September 7, 2020
  • 4 replies
  • 1665 views

I am using STM32L496ZG nucleo board for interface MEMS MPL3115A2 Sensor using I2C interface . First i am scanning I2C device and find attached device too.But after scanning device whenever i tried to read Who am i register , i don't receive correct data and receive 0X00 instead of register value.

Datasheet for breakout board -https://cdn-shop.adafruit.com/datasheets/1893_datasheet.pdf

Code for Scanning device and read Who am i register using STM32Cubeide.

/*define--------------------------------------*/

0693W000003QtjUQAS.png

/*Scan device----------------------------*/

0693W000003QtkXQAS.png

/*Read who am i register--------------*/

0693W000003QtkmQAC.png

And this is settings to configure I2C in STM32cubMX.

0693W000003QtnlQAC.png

This Sensor breakout board is working with other controllers finely ,But not with this STM32 board .

Please help me out from this . Is there any changes need to do in Hardware or in configuration?

    This topic has been closed for replies.

    4 replies

    ST Employee
    September 11, 2020

    Hi @Community member​ ,

    I added STM32 topics for more support. I would suggest you to check the operating voltage of MPL3115A2. 3.3V should be OK. Please note that on the sensor datasheet is reported that "This board/chip uses I2C 7-bit address 0x60", so you have to make sure you are communicating I2C 7-bit (seems OK from your screen). You can double-check whether this is true if the device address you get with the scanning is actually 0x60.

    -Eleon

    ST Employee
    September 17, 2020

    Hi @Community member​ ,

    do you have any news on this topic from your side?

    -Eleon

    Visitor II
    July 22, 2024

    I have the same issue, any update on this topic?

    Visitor II
    August 20, 2024

    I am using the Nucleo STM32L432KC, but it should also work with any other Nucleo. You must use the

    HAL_I2C_Mem_Read

    function. Then it should work.
    Device address: 0x60
    Who am I register: 0x0C
    Expected return value: 0xC4

    uint8_t addr = 0x60 << 1;
    uint8_t trans_data[1] = {0x0C}; //0x0C is the "Who am i" register
    uint8_t rec_data[1] = {0x00};
    while (1) {
    //works:
    HAL_I2C_Mem_Read(&hi2c1, addr, trans_data[0], sizeof(trans_data) / sizeof(trans_data[0]), rec_data,sizeof(rec_data) / sizeof(rec_data[0]) , 1000);
    //does not work:
    HAL_I2C_Master_Transmit(&hi2c1, addr, trans_data, sizeof(trans_data) / sizeof(trans_data[0]), 1000);
    HAL_I2C_Master_Receive(&hi2c1,addr, rec_data, sizeof(rec_data) / sizeof(rec_data[0]), 1000);
    break;
    }