udawat / Explore-Labs-3D-Accelerometer-3D-Magnetometer-LSM303D-Compass-Breakout-Board

The LSM303D is a system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor that is ideal for making a tilt-compensated compass.
http://www.explorelabs.com/explore-labs-3d-accelerometer-3d-magnetometer-lsm303d-compass-breakout-board-5v-ready-with-voltage-regulator
5 stars 4 forks source link

LSM303D Click Interrupts #1

Open tcannon79 opened 7 years ago

tcannon79 commented 7 years ago

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

#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;
}

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?

udawat commented 7 years ago

Do not have a DLHC sensor to test the code. But, it looks like the LSM303D and LSM303DLHC sensors are quite different. Like, there is no CTRL0 register in the DLHC.

Pololu's library does have support for different variants of the LSM303 sensors. You might want to take a look at the datasheets.