XIAO nRF52840 free-fall detection not working

So Hi there,
I see you have been asking over on Arduino. That volatile discussion is important but NOT pertinent to this Code. BTW. You missed ONE major detail.
Here is the output and a small clip of it in action.

Device OK!
Success to Configure!
Free fall detected!  1
Free fall detected!  2
Free fall detected!  3
Free fall detected!  4
Free fall detected!  5
Free fall detected!  6
Free fall detected!  7
Free fall detected!  8
Free fall detected!  9
Free fall detected!  10


HTH
GL :slight_smile: PJ

https://www.st.com/en/mems-and-sensors/lsm6ds3tr-c.html#
https://www.st.com/resource/en/application_note/an5130-lsm6ds3trc-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf

Section Interrupt generation and Section 5.2 more specifically. About the Zone, the free fall zone consist of the time duration and threshold, you asked what do you write there, well based on the scales you choose you can adjust the levels and duration of ““Zero G”” closest to Zero on all axis = Free Fall
You didn’t notice in my Double tap code I , enable the interrupt for the 2 Tap writing an 0x81
Section 5.2 in the fine print :smiley:

 The basic interrupts (6D/4D, free-fall, wake-up, tap, inactivity) have to be enabled by setting the
INTERRUPTS_ENABLE bit in the TAP_CFG register.

Changing your 0x01 to 0x81 and Wha-la… Interrupt generation.

:stuck_out_tongue_winking_eye: :point_up_2:
error += lsm6ds3.writeRegister(LSM6DS3_ACC_GYRO_TAP_CFG1, 0x81);

1. Write 60h to CTRL1_XL // Turn on the accelerometer
// ODR_XL = 416 Hz, FS_XL = ±2 g
2. Write 81h to TAP_CFG // Enable interrupts and latch interrupt
3. Write 00h to WAKE_UP_DUR // Set event duration (FF_DUR5 bit)
4. Write 33h to FREE_FALL // Set FF threshold (FF_THS[2:0] = 011b)
// Set six samples event duration (FF_DUR[5:0] = 000110b)
5. Write 10h to MD1_CFG // FF interrupt driven to INT1 pin
The sample code exploits a threshold set to 312 mg for free-fall recognition and the event is notified by hardware
through the INT1 pin. The FF_DUR[5:0] field of the FREE_FALL / WAKE_UP_DUR registers is configured like this
to ignore events that are shorter than 6/ODR_XL = 6/412 Hz ~= 15 msec in order to avoid false detections.

1 Like