1

I'm using the I2C library to connect to a GY-521 board and, when executing the getAcceleration() methods I get gyro values and viceversa..

This is my setup (I'm using a proto shield but that shouldn't change anything as far as I understand):

enter image description here

It follows this schematic:

enter image description here

And this is the code I'm testing:

#include "Wire.h"

#include "MPU6050.h"

MPU6050 accel;

int16_t ax, ay, az;

void setup() {
    Wire.begin();
    Serial.begin(9600);
    Serial.println("Initializing I2C devices...");
    accel.initialize();
    Serial.println("Testing device connections...");
    Serial.println(accel.testConnection() ? "Connected" : "Connection failed");
}

void loop() {
    accel.getAcceleration(&ax, &ay, &az);
    Serial.print("acc x:    ");
    Serial.println(ax);  // This prints the gyro value of the Y axis!
    delay(1000);
}

I don't think it has to do with the wiring since inverting the 4 and 5 analog pins yields zero values.

Is this a problem with the library? Or with my chip?

3
  • 1
    I think this has to be a problem with the library, or with your method of discerning which set of values is the accel and the gyro I guess. Gyro should be the one totally zerod out when the sensor is sitting still. Where did you download the library from? – BrettAM Apr 25 '15 at 19:12
  • Yup I'm sure that's the gyro value (I even have a video if you need it). So I'm guessing it's the library... I may just wrap it up with the correct names – Alvaro Apr 26 '15 at 15:59
  • Personally I use accel.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); which yields all values generated by the sensor. Just to be certain, if you use accelgyro.getAcceleration(&ax, &ay, &az); you get Gyro data and if you use accelgyro.getRotation(&gx, &gy, &gz); you get Accelerometer data? If you actually get the values the wrong way around, you could just use the variables in the 'wrong' way, I know this is not how it should work. – Mathieu Brouwers Jan 23 '17 at 11:58
-1

There are a lot of libraries, I wouldn't use the accelerometer library in wire, download and add the I2Cdev library, you can get it on a variety of different sites like github.com

1
  • Would you please develop your answer further? Currently this is not the typical kind of useful answer: no real value, no detail, no reason why "you wouldn't use the accelerometer library..." For me, you could have posted this as a comment to the question. – jfpoilpret Nov 7 '16 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.