Sodaq_LSM303AGR Sara working problem

I am using a SODAQ SARA 412 AFF And SFF.
In my case I use your Uni Tracker example for my code base. I use 5% of 8G sensitivity for Accleration interrupt but som case in my car the device won’t detect motion in some case. And some another rare case when i put the device in specific position the motion continuosly trigger the device.

There is a solution for more reliable operation of the motion sensor ?

In some forum question I read another solution for deep sleep and interrup configuration.
Is it possible that these help?

GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(GCM_EIC) | GCLK_CLKCTRL_GEN_GCLK1 | GCLK_CLKCTRL_CLKEN;

insteed use this:

// enable EIC clock
GCLK->CLKCTRL.bit.CLKEN = 0; //disable GCLK module
while (GCLK->STATUS.bit.SYNCBUSY);

GCLK->CLKCTRL.reg = (uint16_t)(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK6 | GCLK_CLKCTRL_ID(GCM_EIC)); //EIC clock switched on GCLK6
while (GCLK->STATUS.bit.SYNCBUSY);

GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(6)); //source for GCLK6 is OSCULP32K
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) ;

GCLK->GENCTRL.bit.RUNSTDBY = 1; //GCLK6 run standby
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);

and for a sleep methode:

/**
Powers down all devices and puts the system to deep sleep.
*/
void systemSleep() {
// Disable systick interrupt
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
__WFI(); // SAMD sleep
// Enable systick interrupt
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
}

Hi @Istvan_Granoviter ,

I recommend to use a value above 1G (gravity)
15-20% should work good for vehicle movement detection.

Best regards,
Jan

Dear Jan!
I use this code, but must shake very intensive the device for detect the motion.
i feel this is exponentially true in deep sleep .
in code i call initEIC() then initOnTheMove()
Sodaq_LSM303AGR::Scale2g is the lowest option .

void initEIC() {
// Configure EIC to use GCLK1 which uses XOSC32K, XOSC32K is already running in standby
// This has to be done after the first call to attachInterrupt()
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(GCM_EIC) |
GCLK_CLKCTRL_GEN_GCLK1 |
GCLK_CLKCTRL_CLKEN;
}

void initOnTheMove()
{
pinMode(ACCEL_INT1, INPUT);
attachInterrupt(ACCEL_INT1, accelerometerInt1Handler, CHANGE);
accelerometer.enableAccelerometer(
Sodaq_LSM303AGR::LowPowerMode,
Sodaq_LSM303AGR::HrNormalLowPower10Hz,
Sodaq_LSM303AGR::XYZ,
Sodaq_LSM303AGR::Scale2g,
true);
sodaq_wdt_safe_delay(100);
accelerometer.enableInterrupt1(
Sodaq_LSM303AGR::XHigh | Sodaq_LSM303AGR::XLow | Sodaq_LSM303AGR::YHigh | Sodaq_LSM303AGR::YLow | Sodaq_LSM303AGR::ZHigh | Sodaq_LSM303AGR::ZLow,
10 * 2.0 / 100.0,
0,
Sodaq_LSM303AGR::MovementRecognition);
}

Best regards, grano

Hi istvan,

Have you tried using the snippet you posted in your first post?
On a side note, you should avoid using CHANGE if you do not need it. You’ll probably just need RISING. Edit: It’s not bad per se and it appears we do it in the universal tracker. I’ll drop this.

If that doesn’t improve performance, try changing your duration to 16./1000. or 32./1000. to force the lowest values.

Regards,
Thom