2025-04-24 5:47 AM
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
2025-04-30 7:05 AM
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)
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
Moreover in your code you are modifying LSM6DSV_SENSOR_HUB_12 (0x0D)
instead to configure it you should set registers from 0x14 to 0x17 of the sensor hub bank, like functions in the example.