Hi,
I'm trying to configure the accel+gyro MPU6050 gy521 in order to calculate the accelerations in each axis (gyro values come later, first I want to solve this "problem"). This "problem" is that when I print the values, these do not follow the datasheet specifications of the orientation of the three axis. I'll show:
- My code (using Jeff Rowberg library)
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
void setup() {
Wire.begin();
Serial.begin(38400);
Serial.println("Initializing I2C devices...");
accelgyro.initialize();
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed")
Serial.println("Updating internal sensor offsets...");
accelgyro.setXAccelOffset(450);
accelgyro.setYAccelOffset(-300);
accelgyro.setZAccelOffset(-525);
accelgyro.setXGyroOffset(63);
accelgyro.setYGyroOffset(103);
accelgyro.setZGyroOffset(13);
Serial.println("Offsets updated. Press a key to continue");
while(!Serial.available());
Serial.read();
}
void loop() {
accelgyro.getAcceleration(&ax, &ay, &az);
Serial.print("a/g:\t");
Serial.print(float(ax)/16384.0); Serial.print("\t");
Serial.print(float(ay)/16384.0); Serial.print("\t");
Serial.print(float(az)/16384.0); Serial.print("\t");
Serial.println();
}
- The results are shown in the image below.
As you can see, with the board completely horizontal (looking at datasheet it should be Z axis), I get X accelerations, don't know where I fail, of if simply I missunderstand the datasheet...
Thanks in advance