Giter VIP home page Giter VIP logo

motionsensorexample's Introduction

MotionSensorExample
===================

MPU6050/MPU6500/MPU9150/MPU9250 over I2c for RaspberryPi using official Invensense libraries (v5.1):
http://www.invensense.com/developers/index.php?_r=downloads


This is a sample program for testing your MPU Motion Sensor with Rasperry Pi.
It does all the initialization and gathers:
- gyro
- accel
- quaternion
- compass (for MPU9XXX)
- temperature

and calculates Yaw, Pitch, Roll in degrees which in turn is displayed as an output.


**Wiring**
I2C uses only2 wires for data transmission: SCL and SDA
RPi pin 3 -> MPU SDA
RPi pin 5 -> MPU SCL


You will also need to provide power (3.3V) to your MPU. You can use external power or hook it up with RPi.
For example:
RPi pin 1 (3.3V) -> MPU VCC
RPi pin 6 (Ground) -> MPU GND


**Compilation:**
On RPi, edit MotionSensor/Makefile and adjust CXX_OPTS to specify your board (-DMPU6050 for MPU6050, -DMPU9150 for MPU9150), issue make


**Cross compiling:**
Edit all Makefiles in all directories and adjust CXX. Issue make


**Running:**
  make sure you have i2c_dev module loaded (modprobe i2c_dev)
  run mstest
  
*Output:*
Initializing I2C devices...
Testing device connections...
MPU6050 connection successful
Initializing DMP...
Enabling DMP...
DMP ready!
Initializing IMU...
Checking... Done.
IMU init done; offset values are :
yaw = -0.169205, pitch = -1.301078, roll = -1.168776

yaw = -0.174            pitch = 1.325           roll = -1.219   t = 20.24       1       0       0
yaw = -0.179            pitch = 1.350           roll = -1.267   t = 20.22       2       0       0
yaw = -0.185            pitch = 1.372           roll = -1.314   t = 20.23       3       0       0
yaw = -0.190            pitch = 1.395           roll = -1.361   t = 20.21       4       0       0
yaw = -0.195            pitch = 1.418           roll = -1.410   t = 20.23       5       0       0
yaw = -0.201            pitch = 1.441           roll = -1.454   t = 20.23       6       0       0
yaw = -0.206            pitch = 1.465           roll = -1.498   t = 20.23       7       0       0
yaw = -0.211            pitch = 1.485           roll = -1.545   t = 20.23       8       0       0
yaw = -0.216            pitch = 1.506           roll = -1.587   t = 20.23       9       0       0

....

**Additional info:**
Current setup is to run at 40Hz, this can be adjusted in the ms_open function, however note that your code will need to read the values with respective speed or quicker. Otherwise the MPU fifo buffer will overflown.

To read MPU see ms_update - it calls 'dmp read fifo' in a while loop. This means that if fifo is empty this will stall until a packet is available.

-------------------------
Gregory Dymarek

motionsensorexample's People

Contributors

gregd72002 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.