Skip to main content
Visitor II
December 1, 2016
Question

LSM303D Interrupt

  • December 1, 2016
  • 2 replies
  • 969 views
Posted on December 01, 2016 at 12:40

I am having trouble getting the click interrupts to work for the LSM303D. using the library provided by Pololu for arduino I can get this code working for the DLHC

[code]

#include <Wire.h>

#include <LSM303.h>

long thisLong = 0;

LSM303 compass;

const byte interruptPin = 2;

void setup()

{

  Serial.begin(9600);

  Wire.begin();

  compass.init();

  compass.enableDefault();  

  compass.writeAccReg(LSM303::CTRL3,     0b11000000);

  compass.writeAccReg(LSM303::CTRL0,     0b00000000);

  compass.writeAccReg(LSM303::CLICK_CFG, 0b00010000);

  compass.writeAccReg(LSM303::CLICK_THS, 0b00011111);

  compass.writeAccReg(LSM303::TIME_LIMIT, 0b00011111);

  delay(100);

  attachInterrupt(digitalPinToInterrupt(interruptPin), reset, CHANGE);

}

void loop()

{

  Serial.print(thisLong);

  Serial.println('''');

  thisLong++;

  delay(100);

}

void reset() {

  thisLong = 0;

}

[/code]

But when I try it on the LSM303D it doesn't seem to generate the interrupt. I can read the CLICK_SRC register and the interrupt shows active, but the INT1 pin never goes from low to high. Anyone work with these at all?
    This topic has been closed for replies.

    2 replies

    Visitor II
    February 9, 2017
    Posted on February 09, 2017 at 01:19

    Seriously no one has had issues like this?

    ST Employee
    February 9, 2017
    Posted on February 09, 2017 at 10:20

    Unfortunately the complete configuration of the sensor is not visible from you code (for example used ODR?).

    Anyway your configuration for click detection seems to me quite strict, and it is difficult to trigger the interrupt.

    You can try following configuration (ODR=25Hz):

    0690X00000606DVQAY.png