2025-10-22 3:58 AM
Hi,
I am working on a project to read the magnetic field with the IIS2MDCTR chip. Actually, I am replacing a read switch with this accelerometer. I use the IIS2MDCSensor Arduino library. After testing with the magnet, I set the threshold to 10000. Enabled the interrupt on all axes in pulsed mode and routed it to the INT pin to get my microcontroller. (STM32U385VGT6) interrupted. When I close the magnet from the z-direction, I get the interrupt. But when I bring it closure from an angle, it does not change the pin status. I tried printing the ODR register values. I saw one, two, or three register values go beyond the 10000 threshold. But I do not get the interrupt. But when I move from the z direction, I am getting the interrupt even when only one axis exceeds the threshold.
Can somebody explain the situation and advise me to understand this behaviour?
Solved! Go to Solution.
2025-10-27 12:05 AM
Hi, Federica
I tested and found the issue. As I mentioned earlier, the issue was the scaling. I need to correct the threshold value with the scale before loading into the threshold registers. Now everything works fine.
Thanks
2025-10-23 7:53 AM
Hi @pLanka ,
Can you double-check that interrupts are enabled on all three axes in the sensor registers?
Thanks
2025-10-23 10:39 AM
Hi Federica,
Thanks for your quick response.
Yes, I have enabled interrupts on all three axes. I think the issue is with scaling. The values read from the getAxis() function in the library scale the raw register readings and put them as int32 numbers in the given array. But I just set the threshold registers to 10000. I, too, need to scale my threshold with the same scale before loading into the register. I then should compare the printed values with the scaled threshold. I will do that test and update the blog tomorrow.
2025-10-27 12:05 AM
Hi, Federica
I tested and found the issue. As I mentioned earlier, the issue was the scaling. I need to correct the threshold value with the scale before loading into the threshold registers. Now everything works fine.
Thanks
2025-10-28 7:40 AM
Hi @pLanka ,
I'm glad to hear that you've solved your issue.