Jeroen deBuffel

LIS3DH - motion detection

Discussion created by Jeroen deBuffel on Jul 3, 2017
Latest reply on Oct 9, 2017 by Miroslav B

I am looking for a solution in which a sensor can wake up my MCU (Arduino based) based on motion detection occuring. Now I want to use the LIS3DH as the power characteristics are very good.

 

Using the ST AN3308 document I build some basic code which works. However the "amount of motion" which I need to generate an INTerrupt is high (I need to shake the LIS3DH hard).

 

Below a snippet from the code (register values etc)

void init_ACC1(void)
{
    // configurations for control registers
    lis.writeRegister8(LIS3DH_REG_CTRL1, 0x57);                       // Write 0x57 - turn on x, y, z sensor axis with ODR of 100 Hz (0x5x)
    lis.writeRegister8(LIS3DH_REG_CTRL2, 0x00);                       // High-pass filter (HPF) enabled (0x09) (FD1 = 1 and HP_IA1 = 1) or disabled (0x00)
    lis.writeRegister8(LIS3DH_REG_CTRL3, 0x40);                       // ACC AOI1 interrupt signal is routed to INT1 pin. (I1_IA1)
    lis.writeRegister8(LIS3DH_REG_CTRL4, 0x00);                       // Full Scale = +/-2G (2G=0x00, 4G=0x10, 8G=0x20, 16G=0x30)
    lis.writeRegister8(LIS3DH_REG_CTRL5, 0x08);

    lis.writeRegister8(LIS3DH_REG_INT1THS, 0x01);                     // Threshold 16 mg (1 LSB equels xx mg. 2G = 16, 4G = 32, 8G = 262, 16G = 186)
    lis.writeRegister8(LIS3DH_REG_INT1DUR, 0x00);                     // Event(!) duration - can be set to avoid false detections (e.g. to prevent false freefall detections). Duration = 1LSBs * (1/10Hz) = 0.1s.
    lis.writeRegister8(LIS3DH_REG_INT1CFG, 0x0A);                     // Enable the Xh and YH interrupt generation (ZH not activated!)
} // End of init_ACC function

After an interrupt is received I 

 

  if(interruptFlag) {
    Serial.print("\t\tInterrupt received. Read register to clear interrupt: ");
    Serial.println(lis.readRegister8(LIS3DH_REG_INT1SRC));

 

    //ACC1
    lis.writeRegister8(LIS3DH_REG_INT1CFG, 0x0A);                     // Enable the Xh and YH interrupt generation
        interruptFlag = false;
    delay(500);
  }

Is the LIS3DH not sensitive enough for my purpose or am I doing something wrong?

Thanks!

Outcomes