MPU 6050 to Arduino Mega 2560 Connections and code

Hello all,

I am doing a project in which it requires the accelerations of hand. So, I purchased an accelerometer MPU 6050 (GY 521) and Arduino Mega 2560. All I want is to get the accelerations on my desktop screen whenever I move the accelerometer.

Please help me in getting me the connections and code.

A Quick Glimpse:

  1. My connections - Vcc to 3.3v ; GND to GND; SCL to SCL 21; SDA to SDA 20; AD0 to GND;
  2. Message displaying is MPU Connections are failed.
  3. Tried using I2Cdev to check and it is showing I2C devices not found.

How to solve these things?

Thanks a lot in advance.

Rudra

You give us good information about the problem with screen dumps and a photo: very good.

The GY-521 has an onboard voltage regulator for 3.3V. If you supply 3.3V to Vcc, the resulting voltage might be a little lower.
The Mega 2560 is an older chip which requires a high voltage for a valid '1'.
That seems to be the problem.

Solution: Use the Arduino 5V pin for the Vcc of the sensor board.
Or use a level shifter for the I2C signals.

The I2Cdevlib requires an interrupt. Connect INT to pin 2 (pin 2 is int.0).
http://arduino.cc/en/Reference/AttachInterrupt

AD0 has a pull-up or pull-down resistor, you don't have to connect it.
Note: the sensor board is running at 3.3V so if you want it to be high, connect it to 3.3V and never to 5V.

This is basic information to start, Arduino Playground - MPU-6050

To get an i2c device working, try the i2c scanner as the first test.
http://playground.arduino.cc/Main/I2cScanner

Thanks a lot, sir. It is working now. I have sent you a personal message to you. It would be great if you reply to that mail :slight_smile:

Hello.

I'm using this code and I want to know where and how can I able the int 0 on the board and the script

#include <ADXL345.h>
#include <bma180.h>
#include <HMC58X3.h>
#include <ITG3200.h>
#include <MS561101BA.h>
#include <I2Cdev.h>
#include <MPU60X0.h>
#include <EEPROM.h>

//#define DEBUG
#include "DebugUtils.h"
#include "CommunicationUtils.h"
#include "FreeIMU.h"
#include <Wire.h>
#include <SPI.h>

int raw_values[9];
//char str[512];
float ypr[3]; // yaw pitch roll
float val[9];

// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();

void setup() {
Serial.begin(115200);
Wire.begin();

delay(5);
my3IMU.init(); // the parameter enable or disable fast mode
delay(5);
}

void loop() {
my3IMU.getYawPitchRoll(ypr);
Serial.print("Yaw: ");
Serial.print(ypr[0]);
Serial.print(" Pitch: ");
Serial.print(ypr[1]);
Serial.print(" Roll: ");
Serial.print(ypr[2]);
Serial.println("");

delay(10);
}

(deleted)