Hello, this is my first dealing with an IMU and I2C as well, the problem I am having is that I can’t manage to get the accelerometer or gyro values from the MPU 9150. https://www.sparkfun.com/products/11486
I tried a couple of codes, one was a pack of libraries https://github.com/zarthcode/MPU9150Lib and I really didn’t know what I would do with the results because it printed the “output of the data fusion” and I really dont know what that is exactly.
////////////////////////////////////////////////////////////////////////////
//
// This file is part of MPU9150Lib
//
// Copyright (c) 2013 Pansenti, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
// Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <Wire.h>
#include "I2Cdev.h"
#include "MPU9150Lib.h"
#include "CalLib.h"
#include <dmpKey.h>
#include <dmpmap.h>
#include <inv_mpu.h>
#include <inv_mpu_dmp_motion_driver.h>
#include <EEPROM.h>
MPU9150Lib MPU; // the MPU object
// MPU_UPDATE_RATE defines the rate (in Hz) at which the MPU updates the sensor data and DMP output
#define MPU_UPDATE_RATE (10)
// SERIAL_PORT_SPEED defines the speed to use for the debug serial port
#define SERIAL_PORT_SPEED 115200
void setup()
{
Serial.begin(SERIAL_PORT_SPEED);
Serial.println("Arduino9150 starting");
Wire.begin();
MPU.init(MPU_UPDATE_RATE); // start the MPU
}
void loop()
{
if (MPU.read()) { // get the latest data
// MPU.printQuaternion(MPU.m_rawQuaternion); // print the raw quaternion from the dmp
// MPU.printVector(MPU.m_rawMag); // print the raw mag data
// MPU.printVector(MPU.m_rawAccel); // print the raw accel data
// MPU.printAngles(MPU.m_dmpEulerPose); // the Euler angles from the dmp quaternion
// MPU.printVector(MPU.m_calAccel); // print the calibrated accel data
// MPU.printVector(MPU.m_calMag); // print the calibrated mag data
MPU.printAngles(MPU.m_fusedEulerPose); // print the output of the data fusion
Serial.println();
}
}
There are so many libraries here within each other so I’m pretty much lost.
The second one is from http://playground.arduino.cc/Main/MPU-9150 , I liked this one cause I would like to deal directly with the registers using the Wire library only and no other library.
But the strange thing that this code only outputs “36.50 -1 -1 -1 -1 -1 -1 -1 -1 -1” over and over, nothing is changing.
I would really appreciate any help, I have been struggling with this for a couple of days now. Thank you!