cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496ZG +MPL3115A2 interface

RPate.4
Associate

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?

4 REPLIES 4
Eleon BORLINI
ST Employee

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

Eleon BORLINI
ST Employee

Hi @Community member​ ,

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

-Eleon

knowit-jos
Associate II

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

noctura
Associate

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;
}