cancel
Showing results for 
Search instead for 
Did you mean: 

lsm6dsv with lis2mdl sensor hub

Eddess
Associate II

Hello

I would like to get the lis2mdl magnetometer data using the lsm6dsv second i2c line using the sensor hub.

so far I get the accelerometer and gyroscope data via SPI and I want to add the magnetometer data.

The code I have to configure the sensor hub and retrieve the data doesn't work. The i2c line doesn't even move (I checked with an oscilloscope)

I checked with the example here  https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsv_STdC/examples/lsm6dsv_sensor_hub.c#L504 

but I have trouble understanding the code

I have a nucleo board l476RG not the demo board given in the example but since my spi communication works it shouldn't be a problem. I also have several lsm6dsv connected to my MCU but right now I try to make it works for at least one.

I use the lsm6dsv_reg and lis2mdl_reg lib

can anyone tell me what is wrong and why I can't make this i2c line work?? I've been trying for 3 days already

I attached my project 

 

1 REPLY 1
Federica Bossi
ST Employee

Hi @Eddess ,

I saw that you changed the example in which it is set the same communication bus for each device (also the ones used through sensor hub) 

FedericaBossi_0-1746021832355.jpeg

 

 

Then I would suggest to use and follow same functions of the examples like (from line 297):

lsm6dsv_sh_slv_cfg_read

lsm6dsv_sh_data_rate_set

lsm6dsv_sh_slave_connected_set

lsm6dsv_sh_master_set

FedericaBossi_1-1746021832356.jpeg

 

 

Moreover in your code you are modifying LSM6DSV_SENSOR_HUB_12 (0x0D) 

FedericaBossi_2-1746021832358.jpeg

 

instead to configure it you should set registers from 0x14 to 0x17 of the sensor hub bank, like functions in the example.

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.