Can MPU6050 detect tap/tapping?

I'm trying to detect tap/tapping motion (possibly two taps) with MPU 6050. However I cannot find any information about the detecting taps on the internet. I've looked through the motion driver software from invensense but the code is too complicated for me to understand (sorry I'm new). I can load the DMP image and toggle the interrupt pins using DMP and motion interrupt status.

After looking through the internet for a while I found this comment saying it might not be possible. I would be really helpful if someone knew any better or had achieved this before.

P.S. I'm using the i2cdevlib library for communicating with the MPU.

you have a 3-axis Accelerometer and 3-axis Gyroscope inside the MPU. So the question you need to ask yourself is "how can a tap impact one or both of those"

➜ if the MPU is attached on a mobile or flexible element that can be impacted by the taps, then chances are that you'll measure a change from the sensors. if the MPU does not move (including rotate) at all when you tap, then the sensors won't record anything

it's probably not the easiest component to use to record a tap, a piezo mounted securely on the surface (ideally wood or metal to conduct sound / vibration well) usually works in an easy way

My MPU will have metal shell around, well actually the PCB containing the MPU and MCU will be inside a metal shell.

However how to I detect the taps, I'm guessing one can use the DMP (FIFO) and accelerometer to detect taps (I could be wrong) but the register map doc or the mpu6050 doc doesn't include anything about using (or how to use) the tapping feature

again, if your MPU does not move, you won't register any acceleration or rotation. So the question is "does the tap create a move?"

Yes it does. I've tried moving the MPU by hand and gently shaking it too.

But that's not the question, I want to know how to use the tap feature. I've been reading some 9250 code and made a callback for tap and I've registered it. But the function never gets called. I'm following the invensense motion driver code (6.x).

yes it can.

the 9250 library leverages the DMP (Digital Motion Processor which fuses the accelerometer and gyroscope data together) offers tap detection. You can see the code to enable various DMP features (dmp_enable_feature()) here

The tap feature is available as well it seems in the DMP of the MPU60X0 but I've not seen it being made available in the usual libraries for the 6050

Thanks for, but how do I use it? Like after loading the DMP image/firmware and registering the tap callback what do I do?

Tips or advice is appreciated.

That's the issue I couldn't find anything related to tapping for MPU6050. I've seen the MPU9250 library, I've a 9250 I'll try checking if it's working on 9250 and use parts from that code for 6050.

You’d need to find the register description

Most probably there are no special register for TAP, it's taken care by the DMP. I tried looking through the register map, both revision 4.2 and 2.1.

Seems like a dead end, and browsing other forums I'm getting a similar kind of feeling too.

there seems to be some kind of configuration needed for the DMP. that's what they do on the 9250

if (mask & DMP_FEATURE_TAP) {
        /* Enable tap. */
        tmp[0] = 0xF8;
        mpu_write_mem(CFG_20, 1, tmp);
        dmp_set_tap_thresh(TAP_XYZ, 250);
        dmp_set_tap_axes(TAP_XYZ);
        dmp_set_tap_count(1);
        dmp_set_tap_time(100);
        dmp_set_tap_time_multi(500);

        dmp_set_shake_reject_thresh(GYRO_SF, 200);
        dmp_set_shake_reject_time(40);
        dmp_set_shake_reject_timeout(10);
    } else {

You are way overthinking this. I have an MPU6050 connected to an ESP32 and some other stuff on the desk next to me. I tapped the MPU6050 and I get an immediate change in the raw accelerometer reading. This project isn't even using the DMP library.

How are you differentiating between a tap/s and noise. I thought the gesture data decoding was done by DMP

Depends on how much distance you need between tap and noise. If the tap is going to be down near the noise floor, then you will probably want to use whatever features the DMP has to discriminate. If you're looking for a healthy knock, that's easy enough to detect by looking at the difference from the background.

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