element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sensors
  • Technologies
  • More
Sensors
Blog A step closer to create fall detector with MPU6050
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Sensors to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: embeddedguy
  • Date Created: 28 Apr 2022 5:02 PM Date Created
  • Views 6166 views
  • Likes 7 likes
  • Comments 3 comments
  • sensors
Related
Recommended

A step closer to create fall detector with MPU6050

embeddedguy
embeddedguy
28 Apr 2022

During last some days, I was working on creating a sensor library for MPU6050.  In this blog I want to explain what I have done so far with this sensor.

The MPU6050 comes with onchip Accelerometer and Gyroscope. The sensor can measure acceleration range from +/- 2g, 4g, 8g, 16g. 

And it can measure Gyroscope angular velocity of +/- 250, 500, 1000, 2000 LSB/degree/s. 

At present, the library can measure x,y,z acceleration. But my plan is to create a fall detector with interrupt capability. Perhaps the Gyro data can also be used for this purpose.

MPU6050 Library

Update

The last time I wrote the blog, I had no idea about interrupts for MPU6050 and how they work. Though, there are some documentation issues, some people have reverse engineered the I2C signals to find out which registers are for Fall detection

and motion detection.

The register 0x38(Interrupt Enable) has two separate bits for enabling/disabling the fall detection and motion detection interrupts on pin INT of the sensor.

//interrupt Registers

#define INT_PIN_CONFIG 0x37
#define INT_ENABLE 0x38
#define INT_STATUS 0x3A

#define MOT_THR 0x1F
#define MOT_DUR 0x20

#define FF_THR 0x1D
#define FF_DUR 0x1E

Hence, the following code will enable the motion detection interrupt on pin INT.

imu.writebyte(INT_PIN_CONFIG,0x20);
imu.writebyte(INT_ENABLE, 0x40);

imu.writebyte(MOT_THR, 0x01);
imu.writebyte(MOT_DUR, 0x01);

The motion detection works for now, the next part is to check the fall detection and how accurate it is.. 

Update

So now the time is for the fall detection and playing with it tuning some values which could rightly detect the fall based on accelerometer values.

The datasheet or the product specification document mentions this in somewhat detail but many thing are there which is yet not clear.

The first thing is what is the fall detection threshold and it's range? The document says that a threshold in a range of 1mg can be set using the register FF_THS. 

So I thought that setting it to the value 0xFF would be arround  250mg right?

The document further explains that if all there values of acceleration axes from (X, Y, Z) are less than this value than a fall detection interrupt will be triggered.

Though setting 0xFF was to much sensitive. If I would just touch the sensor then also interrupt will be triggered.

Then I tried the value 0x00 to just see what corresponds to the least value of FF_THS register? The interrupt trigger should be the case only if sensor moves from with high acceleration.

This was the case indeed. The interrupt never triggered with me trying to drop sensor from some height.

Finally, for fall detection it was required that I set a value of this register such that if there is an interrupt if the sensor is dropped from an height from about ~5/6 feets in different orientations. 

Of course, the sensor has a filter to nullify the effects of gravity. This would help create better fall detection and identify the right movement.

The value one might want to set for the detection could be around 0xD0 etc.?? For my case it seems working but I still need to do some experiments.

Update

There were a few challenges to create this library but there are obviously many improvements and especially expansion to this library I am looking for.

The next things I am looking to do is following

  • Improve the overall design of the library
  • Create a fusion algorithm to get right angle and speed/tracking information
  • create self-test functions and also add external sensors to fetch I2C data from for examples mangnetometers.

I will keep working on this library and post updates to this blog. If anyone want to join or have some feedback you can contact me!

Update

The final thing for now for this code is to create a library structure as recommended by Arduino hence it can be used by others via .zip download.

For that one needs to put the code in the standard format. The format contains the following structure

  • /src
    • MPU6050.cpp
    • MPU6050.h
    • MPU6050reg.h
  • /examples
    • Example name
      • example.ino
  • /docs
  • library.properties
  • /extras
  • README.md

Out of these files the .properties file is important as it is used by the build systems to generate and compile the example files to create binary.

The things did not work for me in the first go because I was not creating the library inside a library folder of arduino installation.

But anyways the things should work for you if you download the library and would like to get the sensor data!!

Have fun Just like me!!

Update

In the meantime, I created a PCB for MPU6050 and here are the images. There is one 4-pin connector for I2C interface and there are other pin headers for signals such as Auxilary I2C, frame synchronization, Interrupt and external clock input.

imageimageimage

image

 

  • Sign in to reply
  • embeddedguy
    embeddedguy over 3 years ago in reply to embeddedguy

    One of the issue was that of documents does not mention the fall detector and other motion based registers in register description file and also in product specification. But I have found the other version online and a link which mentions all the registers.

    http://www.i2cdevlib.com/devices/mpu6050#registers

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • embeddedguy
    embeddedguy over 3 years ago in reply to mp2100

    The specification has also accelerometer data described. The accelerometer can measure +/- 2,4,8,16g at a maximum rate of arround 260Hz and you can confidure this to lower rate such as 4Hz.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mp2100
    mp2100 over 3 years ago

    I bought one of these on amzn recently. I haven’t used it yet. It’ll be interesting to see how you make progress. 

    The specifications all list the Gyro deg/sec.   Do you know the accelerometer speed?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube