Go Down

Topic: MPU 6050 to Arduino Mega 2560 Connections and code (Read 12134 times) previous topic - next topic


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.


May 13, 2013, 08:52 am Last Edit: May 13, 2013, 08:54 am by Erdin Reason: 1
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).

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, http://playground.arduino.cc/Main/MPU-6050

To get an i2c device working, try the i2c scanner as the first test.


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 :)



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() {
  my3IMU.init(); // the parameter enable or disable fast mode

void loop() {
  Serial.print("Yaw: ");
  Serial.print(" Pitch: ");
  Serial.print(" Roll: ");

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131