Use the SEN-18020 (ISM6DSO) to detect a bump

I have a rolling robot car that I’m trying to detect when it hits something. I’m using “writeRegister()” to set the interrupt parameters such that when it hits something, an interrupt will occur. So far, I have the following setup.

  #include "SparkFunLSM6DSO.h"
#include "Wire.h"

LSM6DSO myIMU; //Default constructor is I2C, addr 0x6B

bool  BumpDetected = false;
int   Interrupt1_Pin = 14;  //GP14 on ESP32_DevModule

void Interrupt1();

void setup() 
{
  delay(1000);  

  Serial.begin(115200);
  delay(500);   
  Wire.begin();
  delay(10);
  if( myIMU.begin() )
    Serial.println("Ready.");
  else 
  { 
    Serial.println("Could not connect to IMU.");
    Serial.println("Freezing");
  }

  if( myIMU.initialize(BASIC_SETTINGS) )
    Serial.println("Loaded Settings.");

  pinMode(Interrupt1_Pin, INPUT);
  attachInterrupt(digitalPinToInterrupt(Interrupt1_Pin), Interrupt1, RISING);

  // Single TAP setup
  myIMU.writeRegister(0x60, CTRL1_XL);    // Turn on the accelerometer
  myIMU.writeRegister(0x0E, TAP_CFG0);    // Enable tap detection on X, Y, Z-axis
  myIMU.writeRegister(0x02, TAP_CFG1);    // Set X-axis threshold and axes priorty
  myIMU.writeRegister(0x82, TAP_CFG2);    // Set Y-axis threshold and enable interrupt
  myIMU.writeRegister(0x02, TAP_THS_6D);  // Set Z-axis threshold
  myIMU.writeRegister(0x03, INT_DUR2);    // Set Quiet and Shock time windows
  myIMU.writeRegister(0x00, WAKE_UP_THS); // Only single-tap enabled (SINGLE_DOUBLE_TAP = 0)
  myIMU.writeRegister(0x40, MD1_CFG);     // Single-tap interrupt driven to INT1 pin  
}

void loop()
{ 
  if(BumpDetected == true)
  {     
    Serial.println("Bump Detected");   
  }
  
  BumpDetected = false;  

  delay(10);
}

void Interrupt1()
{
  BumpDetected = true;
}

I have it set to detect, I think, 2g’s. I cannot get it to cause an interrupt no matter what I seem to do. Does anyone have any ideas to help? I’m using the Qwiic connector with INT1 wired to GP14.

Terry

Try moving it to a different GPIO pin…any difference? If not, you might test the sensor with another board, scope, etc to ensure it’s outputting a signal

Share a photo of the wiring/setup

I tried Int2 also, swapped pins, swapped another LSM6DSO module, tied down Int1 with a 10k resistor. I tried pulling the interrupt wire and then got an interrupt. Otherwise no change.

Has anyone tried this? If so, let me know if it works or doesn’t work for you.

Terry