2026-04-27 7:11 AM - last edited on 2026-04-27 7:25 AM by Andrew Neil
Hello everyone,
I'm working with the LIS2MDL sensor (steval_mki181v1) , i made a connection between it and the nrf5340 and I configured it over I2C with pull-up resistors enabled.
-VDD -- > VDD
-VDDio --> VDD
-CS --> VDD
-PIN I2C :: SCL to SCL et SDA to SDA
-GND t GND
Current configuration:
I2C communication working (i got the chip id 0x40)
Block Data Update (BDU) enabled
Output Data Rate tested at 10 Hz or50 Hz
Offset cancellation enabled
Continuous mode enabled
However, I noticed that the values I read from the sensor remain almost always the same and do not update as expected, as shown in the photo below.
Could anyone help me understand what might be causing this issue or guide me on how to troubleshoot it?
Any help would be greatly appreciated. Thank you!
2026-05-18 8:49 AM
yes i tried this example with the same configuration.
About this "You didn't answer about the pullups, or schematic." yes i added the pullpus for i2c , what about schematic ??
2026-05-18 9:07 AM
I asked what pullups did you use - what value?
@ASREB wrote:yes i tried this example with the same configuration.
And did it work?
@ASREB wrote:what about schematic ??
Post it!
You moan about people not answering, but then don't provide information asked for.
How to write your question to maximize your chances to find a solution
2026-05-18 9:13 AM
i used steval-mki181v1 (with lis2mdl sensor)with this schematic ::
VDD -- > VDD
-VDDio --> VDD
-CS --> VDD
-PIN I2C :: SCL to SCL et SDA to SDA
-GND t GND
About the configuration , yes the sensor response with XYZ data but they stay the same data ( but in the configuration i put continuous mode and not single shot).
2026-05-18 9:28 AM
That's not a schematic - that's just a text list.
Again, a schematic is a far better way to convey this information.
You still haven't said what pullups did you use - what value ?
@ASREB wrote:the sensor response with XYZ data but they stay the same data
Is that using the ST example ?
What changed do you thing should happen in the data?
How are you forcing those changes?
Remember that we know nothing about you, your project, or your setup - it is entirely up to you to provide clear and complete descriptions.
Again, please see: How to write your question to maximize your chances to find a solution
2026-05-18 9:53 AM
About the pull-up, I enabled the software pull-up.
Regarding the schematic, you can also find the related figure attached.
For the ST example, I didn’t make any modifications. I simply used the same configuration and then read the XYZ data. However, the data is always repeated, as shown in the figure.
One thing I noticed is that if I reboot the board sometimes (power off/on), I get new data values, but then those values remain repeated again until the next reboot.
I hope my response clear.
Thanks a lot for your help.
I appreciate your efforts.
2026-05-18 10:14 AM
@ASREB wrote:About the pull-up, I enabled the software pull-up..
You mean the internal pullups - inside the STM32 or the nRF ?
These are unlikely to be suitable for I2C - their value is too high.
Again, have you looked with a scope to verify that you have good signals on the I2C wires?
@ASREB wrote:the data is always repeated, as shown in the figure..
Again, what are you doing that would make it change ?
Have you used a logic analyser to see what's actually happening on the wires ?
ie, is the sensor itself sending constant data, or is your software just ignoring updates ?
2026-05-19 7:19 AM
Hello,
I checked I2C and another fature....
I found the issue but I don't fully understand how to resolve. Just to more explain u, I am working with an nRF5340 board and the LIS2MDL sensor. When I reboot the board to retrieve the X, Y, and Z magnetic values, I always get exactly the same values, even after rebooting multiple times. While investigating the problem further, I noticed something strange: when I disconnect the UART pins, the values li2mdl change. Each time I connect or disconnect the UART pins, the sensor values update.
2026-05-19 7:31 AM - edited 2026-05-19 7:35 AM
You still haven't said what pullups you're using !
As noted, correct pullups are critical to correct & reliable operation of I2C.
Do you see the same behaviour on an ST board ?
How, exactly, do you "connect the UART pins" ?
Bizarre behaviour like this is often due to poor connections; particularly poor GND and/or VDD connections - see this post.
Again, have you used an oscilloscope to see what's actually happening on the wires?
PS:
The X-NUCLEO-IKS4A1 features an LIS2MDL