How do I use an accelerometer to detect and count the number of shakes a device receives?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I use an accelerometer to detect and count the number of shakes a device receives?

315 Views
curtnaumann
Contributor I

I have a cylinder with an attached MMA8652 accelerometer.  Initally, the cylinder is at rest and vertical on a flat surface (i.e. table).  Once the cylinder is picked from the table and tilted away from vertical,  it is then shaken back and forth.  

Where can I find code that is able to detect a back and forth shake (a single shake cycle) and count the number of shake of complete and/or partial shake cyles?  

Thank you,

-Curt

0 Kudos
1 Reply

215 Views
darioarias
NXP Employee
NXP Employee

Hi Curt,

This can be done easily by using the motion detection, which is an embedded  functionality of the MMA8652FC (See section 5 of the datasheet). You just have to configure the direction and position where you want to detect motion.

Attached you can find an example of a project that uses motion detection with the MMA8451Q which is a very similar accelerometer. In this particular application is centered in freefall detection, but if you modify the threshold and axis you want to detect the motion, then you can use it for you application.

Darío

0 Kudos