Go Down

Topic: GY-521 gyroscope/accelerometer breakout board (Read 68901 times) previous topic - next topic

profgeof2000

I would find a real circuit diagram where?  Can't find one with the above hints

kubarbaz

First of all sorry for my english.

I've just bought my Arduino Due and GY-521 today and i was looking for solution quite long time. I just want to share my little bit of knowledge.

SCL and SDA pins are 21 & 20 at the right end of the board in DUE.

And i've seen ridiculous error message in my compiler which i can't find anymore . I've changed line between -------------------  in that code and worked for me . You guys can try that .
Code: [Select]

// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
#include<Wire.h>
-------------------------/*const int MPU=0x68*/;--------------  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
  Wire.begin();
  Wire.beginTransmission([glow=yellow,2,300]-------------------0x68----------[/glow]);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission([glow=yellow,2,300]---------------0x68----------------[/glow]);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}


Basically i've eliminated MPU variable and put adress directly instead. Hope it helps.

JotaStar

Hi,

I'm having troubles reading values from GY-521 to my Arduino Pro Mini.

I get the basic code from Arduino Playground http://playground.arduino.cc/Main/MPU-6050#short

And this Is that i get:

AcX = 254 | AcY = 0 | AcZ = 104 | Tmp = 35.02 | GyX = 7680 | GyY = 30 | GyZ = 0
AcX = 254 | AcY = 0 | AcZ = 104 | Tmp = 35.02 | GyX = 7680 | GyY = 30 | GyZ = 0
AcX = 254 | AcY = 0 | AcZ = 104 | Tmp = 35.02 | GyX = 7680 | GyY = 30 | GyZ = 0
AcX = 254 | AcY = 0 | AcZ = 104 | Tmp = 35.02 | GyX = 7680 | GyY = 30 | GyZ = 0

Always the same values.

MPU es connected by this way:

VCC => 5v
GND => GND
SDA / SCL => A4 / A5
INT = Digital Pin 2 (I tried 3 too)
(also i tried to change A4 for A5 and vice versa)

And, if I try to use the library https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 I always get the message that Connection Failed.

I tried to the I2CTester and it founds the IMU at 0x68 (as expected)

Any idea?

Thank you very much.

StevenRS11

So, I have one of these working well, and saving data to a SD card. One thing Im having trouble with though is changing the default sensitivity of the accelerometers.

I see from here that 0x1C is the register for accel settings, but this code:

  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x1C);
  Wire.write(3);
  Wire.endTransmission(true);

does not seem to have any affect.

Is there something that I am missing?

Go Up