Adafruit_MPU6050 Motion Detection

Good afternoon. Please excuse my question. I really need help. I am using Adafruit_MPU6050 library. Please tell me if I can determine which threshold was exceeded at the moment in mpu.getMotionInterruptStatus(). Maybe I'm not explaining clearly, unfortunately I don't speak English well. I have mpu.setMotionDetectionThreshold(1) set. But I need that when the threshold = 1 is exceeded, one notification comes, and when the threshold = 5 is exceeded, another notification comes. Is it possible to understand that when mpu.getMotionInterruptStatus() exceeded the threshold exactly = 5? I hope you understand me))) Thank you in advance!

You can make your code decide if conditions are not met, met and exceeded by using "if..then" statements: when the threshold = 1 is exceeded, one notification comes, and when the threshold = 5 is exceeded, another notification comes.

You could also make your code do functions when specific conditions are met using "switch..case" statements: threshold exactly = 5

You might find both are valuable, or only one suits your needs.

I understand this)) I don't understand which condition to specify? After all, the library does not have a function to find out which threshold was exceeded.

Maybe I'm not explaining clearly
Here's roughly what I want:

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>

Adafruit_MPU6050 mpu;

void setup() {
  Serial.begin(115200);
  mpu.begin();
  mpu.setHighPassFilter(MPU6050_HIGHPASS_0_63_HZ);
  mpu.setMotionDetectionThreshold(1);
  mpu.setMotionDetectionDuration(20);
  mpu.setInterruptPinLatch(true);
  mpu.setInterruptPinPolarity(true);
  mpu.setMotionInterrupt(true);
}

void loop() {

  if (mpu.getMotionInterruptStatus()) {

    if ( //threshold 5 exceeded)
  {
    Serial.println("HIGH");
    }
    else
    {
      Serial.println("LOW");
    }
  }
}

The thresholds will be values you must set in your code... What value is a "1" versus what value is a "5"? Here is an example of sampling acceleration values (see page 9) where they set the accelerometer range, then shown the values (page 10):

I don't think this is exactly what I need.
mpu.getMotionInterruptStatus() operates on the specified threshold in mpu.setMotionDetectionThreshold(). And I don't need to specify any values for this threshold. How does the library determine which immeno value has been exceeded?

The .cpp shows a getAccelerometerSensor(void) passing a pointer to Adafruit_Sensor (your other #include<> file). The lower level code also likes to multiply a reading by a constant for gravity. Find documentation describing useful data from Adafruit_MPU6050 and and Adafruit_Sensor. Try finding the raw data from the instances your code uses.

Side note: i hate to read a lot of words, but finding a needle in a stack of needles is discovery, and fun. What's the worst thing to happen? You design an ejection seat that turns test pilots into slurry of cells? (but really, that's how bad it can get... treat every project like an ejection seat - find those needles).

I think you are looking to define the size of "1" versus the size of "5."

Or, I am completely wrong. (yes, only trust yourself).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.