MPU6050 - GY 521 with Arduino UNO R3 stuck at "Initializing I2C devices..."

Hi Guys,

I am a newbie to Arduino. I am trying to build myself a Self-Balancing Robot using Arduino UNO R3, MPU 6050 GY-521, and L293D Motor Driver Circuit. I am also using I2Cdevlib for MPU Values. Initially, in order to check whether all the components are working properly (because I shipped them overseas), I tried uploading blink on UNO and it worked. So, I know the Board is good. When I tried MPU6050 YPR, initially I had trouble later I got the values somehow (I don’t know how), but again I was pushed back to square 1. Initially, i had a problem where when I opened the Serial Monitor, it got stuck at “Initializing I2C devices…” later somehow it got fixed and I was able to see YPR values. But again it got stuck at “Initializing I2C devices…” and doesn’t move or respond beyond that. I even tried I2C Scanner and the Serial Monitor was stuck at “Scanning…” My Pin Connection

A4 → (SDA)

A5 → (SCL)

3.3V → VCC

GND → GND

2 → INIT

Please help me figure this one out. Am I making mistake in the Program or the Hardware connection or the Hardware itself? I even tried 5V but of no use for VCC

Code - http://pastebin.com/wDQyHHVN

Please help me in this one

Excellent Project

Looks Exactly like mine :) Balancing Bot I made

I See you are using a version ofJeff Rowberg code What is your plan?

GY 521 has a voltage regulator on the VCC pin to provide the mpu6050 with 3.3v so you should supply the GY 521 with 5V

Z

Hi zhomeslice,

I have tried even with 5V and got stuck with the same place. What is the next thing i should try to do ?

Thanks

If you applied 5V to a 3.3V sensor (e.g. accidentally expose the data pins to 5V), you destroyed it.

jremington: If you applied 5V to a 3.3V sensor (e.g. accidentally expose the data pins to 5V), you destroyed it.

look closely and don't scare him... It is protected! It has a 3.3 V regulator with its own pull up resistors on the 3.3V i2c Bus |500x292

HarzSR: Hi zhomeslice,

I have tried even with 5V and got stuck with the same place. What is the next thing i should try to do ?

Thanks

lets try this program to see if we are communicating. This is an i2c Scanner

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
bool blinkState = false;
#include 


void setup()
{
  Wire.begin();

  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
  pinMode(3, OUTPUT);
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
        blinkState = !blinkState;
        digitalWrite(3, blinkState);
      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

No, the module is not protected.

If either the SDA or SCL input is accidentally exposed to 5V via a data pin, the module will almost certainly be destroyed.

Normally the Wire library does not do this, but beginners make mistakes and quite frequently destroy these modules. I recommend using level shifters on both data lines for exactly this reason.

jremington:
No, the module is not protected.

If either the SDA or SCL input is accidentally exposed to 5V via a data pin, the module will almost certainly be destroyed.

Normally the Wire library does not do this, but beginners make mistakes and quite frequently destroy these modules. I recommend using level shifters on both data lines for exactly this reason.

So without getting into details on how i2c protocols, the wire and twi libraries work the only way he could destroy his MPU6050 is if he wired it to a pin set to output and and and set to HIGH.
6096502cd08e6168d5b9329c1615bf939a65ce3f.jpg
the black wire to AD0 is dangerous and is not needed due to the pull down resister already on the GY521 breakout. I would remove the AD0 jumper to ground. If AD0 is hooked to anything but 3.3V the chip is damaged.
The Int wire hooked to pin 2 could damage the MPU 6050 if hooked to 5v.
If the i2c bus wires are hooked to any power source set as a current output could damage the i2c bus including the arduino UNO’s
His code only enables pin 13 as an output. everything else should default to inputs.
Now I am assuming that this is how he hooked up his MPU6050 and I do not see any issues.
We need to help troubleshoot his i2c communications and get past this freezing issue.

HarzSR did the MPU6050 respond to the i2c scanner sketch I posted for you?

Thank you for the response guys. I haven't tried your code yet zhomeslice as i have ordered new sensors. As you suggested, may be AD0 connection would have been dangerous. I have been in class this week, let me try it tomorrow and post the results, may be with the new sensor. And i am double positive that i haven't provided HIGH or 5V to INIT or AD0. AD0 has been set to ground only. Let me do this connection on the new sensor without the AD0 and try your code and post it by noon. Thank you for the great help sir

HarzSR: Thank you for the response guys. I haven't tried your code yet zhomeslice as i have ordered new sensors. As you suggested, may be AD0 connection would have been dangerous. I have been in class this week, let me try it tomorrow and post the results, may be with the new sensor. And i am double positive that i haven't provided HIGH or 5V to INIT or AD0. AD0 has been set to ground only. Let me do this connection on the new sensor without the AD0 and try your code and post it by noon. Thank you for the great help sir

I'm following your posts. once we get the mpu6050 figured out I have additional code that could help with your balancing bot :) Z

Hi zhomeslice,

I tried the following the code which you provided. Here is the Screen shot of the results. I have not connected the AD0 to GND. The rest of the connection is same. Am awaiting my new sensor this even, so will post another response of the same code in another reply. Okay. And once again thanks for your help. The other pin connection right now

Digial 2 - INIT
Analog A5 - SCL
Analog A4 - SDA
Power 3.3V - VCC
GND - GND

I read somewhere (don’t know where) but it might take 15 minutes for the sensor to respond. This circuit was kept as such as long as 20 minutes but still no response. And as you said, i am trying to learn the basic and replicate exactly what you did in this video.

HarzSR: Hi zhomeslice,

I tried the following the code which you provided. Here is the Screen shot of the results. I have not connected the AD0 to GND. The rest of the connection is same. Am awaiting my new sensor this even, so will post another response of the same code in another reply. Okay. And once again thanks for your help. The other pin connection right now

Digial 2 - INIT Analog A5 - SCL Analog A4 - SDA Power 3.3V - VCC GND - GND

I read somewhere (don't know where) but it might take 15 minutes for the sensor to respond. This circuit was kept as such as long as 20 minutes but still no response. And as you said, i am trying to learn the basic and replicate exactly what you did in this video.

VCC has a 3.3 v regulator on the breakout board. And needs to be supplied with more than 3.3 volts to properly supply the mpu6050 with 3.3V power. Hook up VCC to 5V and try it again. With 3.3V on VCC the mpu6050 may be getting less than 2V and not even powering on. Z

I have had the same problem; however, my sensor gave me correct data even on 5v Why is this? It is still working... It has a green LED and still has good output.

This is what I got from your very helpful program:

I2C Scanner
Scanning...
I2C device found at address 0x68  !
done

Stingray63Vette:
I have had the same problem; however, my sensor gave me correct data even on 5v Why is this? It is still working… It has a green LED and still has good output.

This is what I got from your very helpful program:

I2C Scanner

Scanning…
I2C device found at address 0x68  !
done

great we have found the mpu6050 :slight_smile: it is still good!!!
Now Lets try this code :slight_smile:
This is my basic MPU6050 DMP FIFO code The base for my balancing bot

Z

MPU6050_Latest_code.ino (7.46 KB)

yello zhomeslice

idk if you know, but I'm not the guy trying to build the robot. HarzSR is. Just helping by saying that the MPU6050 actually can take 5v, as there was a debate about it earlier.

Stingray63Vette: Just helping by saying that the MPU6050 actually can take 5v, as there was a debate about it earlier.

You're not helping anyone with such nonsense - the manufacturer's datasheet says the maximum supply voltage for a MPU6050 is 3.46 volts.

AWOL: You're not helping anyone with such nonsense - the manufacturer's datasheet says the maximum supply voltage for a MPU6050 is 3.46 volts.

The MPU6050 can only take 3.46V ! The GY521 breakout board that HarzSR is using has a 3.3V Voltage regulator on it.

GY521 Schematic: |500x292

If you supply the VCC with 3.3V what do you get as a Voltage when it finally gets to the MPU6050?

Z

what do you get as a Voltage when it finally gets to the MPU6050?

That depends on the regulator, but usually it would be (3.3V - dropout voltage).

Stingray63Vette: I have had the same problem; however, my sensor gave me correct data even on 5v Why is this? It is still working... It has a green LED and still has good output.

This is what I got from your very helpful program:

I2C Scanner
Scanning...
I2C device found at address 0x68  !
done

Your welcome :) the program added was what I planned on giving him if he succeeded anyway :) Hopefully HarzSR gets the new GY521 (MPU6050 on a breakout board with a 3.3V Regulator) working and he can try the code I've added.

@zhomeslice - Found out the culprit. Sensor is dead. New sensor is working fine. I tried your code and found this result.

I2C Scanner
Scanning…
I2C device found at address 0x68 !
done

When i tried running the MPU6050 general program or from I2C and got the results for YRP. I have also tried your new Code and got the results too. Am so much happy now. I have screen shots of both the programs.

First screen shot (Values.jpg) for the program that i initially had
Second screen shot (New values.jpg) for the program that you gave latest - MPU6050_Latest_Code

Next what should i do Sir zhomeslice. Please guide me from here. I would like to learn from you.