MPU-6050

Hello,

I am pretty new to Arduino/programming and I have been trying to hook up an MPU-6050.
I have the code written to receive info from the mpu and I am receiving all zeros in the serial port when everything is attached to the mpu EXCEPT the SCL and SDA pins. Once I attach the SCL pin, all info stops flowing into the serial port window and will not start again if I disconnect SCL. The same thing happens when I attach the SDA pin, except once I remove it, I again receive all zeros.

Thanks in advance for any help. I really would appreciate it.

Here is the code and the wiring diagram.

The circuit is wired according to this diagram in the following link:

I have also pulled AD0 low.
I just tried pulling AD0 high and I began seeing all zeros in the serial port window while SDA and SCL were attached. Where as when AD0 was pulled low there was nothing in the serial port window.
However all I can read is zeros there is no response from the sensor.

I just ran the I2C “Scanner Sketch” and when ADO is pulled low, the serial port window just says “scanning”.
When ADO is pulled high, the serial port window finds a I2C connection found at 0x69 !

#include<Wire.h>

const int MPU_addr=0b1101000;

long accelX, accelY, accelZ;
float gX, gY, gZ;
long gyroX, gyroY, gyroZ;
float rotX, rotY, rotZ;

void setup(){
Wire.begin();
startMPU();
Serial.begin(9600);
}

void loop(){
readAccel();
readGyro();
printData();
delay(333);
}

void startMPU(){
//POWER MANAGEMENT
Wire.beginTransmission(MPU_addr); //MPU I2C address is b110100X
Wire.write(0x6B); //PWR_MGMT_1 address
Wire.write(0b00000000); //Prevents sleep mode
Wire.endTransmission(true);
//ACCESS GYRO
Wire.beginTransmission(MPU_addr);
Wire.write(0x1B); //GYRO_CONFIG address
Wire.write(0b00000000); //Full scale range 250deg/sec
Wire.endTransmission();
//ACCESS ACCEL
Wire.beginTransmission(MPU_addr);
Wire.write(0x1C); //ACCEL_CONFIG address
Wire.write(0b00000000); //Full scale range 2g
Wire.endTransmission();
}

void readAccel(){
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); //Accelerometer Measurements adresses
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
accelX = Wire.read()<<8|Wire.read(); //Store first two bytes into accelX
accelY = Wire.read()<<8|Wire.read(); //Store middle two bytes into accelY
accelZ = Wire.read()<<8|Wire.read(); //Store last two bytes into accelZ
//CONVERTS RAW DATA
gX = accelX/16384.0; //LSB sensitivity for 2g scale range
gY = accelY/16384.0;
gZ = accelZ/16384.0;
}

void readGyro(){
Wire.beginTransmission(0b1101000);
Wire.write(0x43); //Gyrometer Measurements adresses
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
gyroX = Wire.read()<<8|Wire.read(); //Store first two bytes into gyroX
gyroY = Wire.read()<<8|Wire.read(); //Store middle two bytes into gyroY
gyroZ = Wire.read()<<8|Wire.read(); //Store last two bytes into gyroZ
//CONVERTS RAW DATA
rotX = gyroX/131.0; //LSB sensitivity for 250deg/sec range
rotY = gyroY/131.0;
rotZ = gyroZ/131.0;
}

void printData(){
Serial.print("AcX = “); Serial.print(gX);
Serial.print(”\tAcY = “); Serial.print(gY);
Serial.print(”\tAcZ = “); Serial.print(gZ);
Serial.print(”\trotX = “); Serial.print(rotX);
Serial.print(”\trotY = “); Serial.print(rotY);
Serial.print(”\trotZ = "); Serial.println(rotZ);
}

Please read the post "How to use this forum" and follow the directions. Post the code, using code tags, and a diagram showing how you have hooked everything up (hand drawn is fine).