Error: 'class MPU6050' has no member named 'begin'

I am trying to interface GY-521 MPU6050 with my Arduino Uno, but not able to run an example code. I have downloaded the necessary libraries for MPU6050 from GitHub. I have even tried to run code with some previous versions of IDE Arduino. I will be grateful, if someone can help.

I am attaching the source code of example.

Given below is the complete error message.

C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master\MPU6050_accel_pitch_roll\MPU6050_accel_pitch_roll.ino: In function ‘void setup()’:

MPU6050_accel_pitch_roll:20:14: error: ‘class MPU6050’ has no member named ‘begin’

while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))

^

MPU6050_accel_pitch_roll:20:20: error: ‘MPU6050_SCALE_2000DPS’ was not declared in this scope

while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))

^

MPU6050_accel_pitch_roll:20:43: error: ‘MPU6050_RANGE_2G’ was not declared in this scope

while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))

^

C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master\MPU6050_accel_pitch_roll\MPU6050_accel_pitch_roll.ino: In function ‘void loop()’:

MPU6050_accel_pitch_roll:30:3: error: ‘Vector’ was not declared in this scope

Vector normAccel = mpu.readNormalizeAccel();

^

MPU6050_accel_pitch_roll:33:23: error: ‘normAccel’ was not declared in this scope

int pitch = -(atan2(normAccel.XAxis, sqrt(normAccel.YAxisnormAccel.YAxis + normAccel.ZAxisnormAccel.ZAxis))*180.0)/M_PI;

^

Multiple libraries were found for “MPU6050.h”
Used: C:\Users\Hp\Documents\Arduino\libraries\MPU6050
Not used: C:\Program Files (x86)\Arduino\libraries\MPU6050
Not used: C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master
Multiple libraries were found for “I2Cdev.h”
Used: C:\Users\Hp\Documents\Arduino\libraries\I2Cdev
Not used: C:\Program Files (x86)\Arduino\libraries\I2Cdev
exit status 1
‘class MPU6050’ has no member named ‘begin’

MPU6050_accel_pitch_roll.ino (1.07 KB)

deependra123:

C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master\MPU6050_accel_pitch_roll\MPU6050_accel_pitch_roll.ino: In function 'void setup()'

deependra123:

Multiple libraries were found for "MPU6050.h"

Used: C:\Users\Hp\Documents\Arduino\libraries\MPU6050
Not used: C:\Program Files (x86)\Arduino\libraries\MPU6050
Not used: C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master

There are your clues. The sketch you're using is at C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master\MPU6050_accel_pitch_roll\MPU6050_accel_pitch_roll.ino, which makes it pretty clear it's intended to be used with the library installed at C:\Program Files (x86)\Arduino\libraries\Arduino-MPU6050-master. But you have multiple other libraries installed that also contain a file named "MPU6050.h". When this happens, the Arduino IDE does its best to pick the best library to use, but in this case it chose the wrong one. This is a common problem because many library authors choose to use incredibly generic file names for their primary header files.

You can force the Arduino IDE to use the correct library by deleting the unwanted libraries at C:\Users\Hp\Documents\Arduino\libraries\MPU6050 and C:\Program Files (x86)\Arduino\libraries\MPU6050. Please be very careful when deleting things from your computer. When in doubt, back up!

deependra123:

Multiple libraries were found for "I2Cdev.h"

Used: C:\Users\Hp\Documents\Arduino\libraries\I2Cdev
Not used: C:\Program Files (x86)\Arduino\libraries\I2Cdev

You seem to have some very bad habits when it comes to installing libraries.

First of all, you should never install libraries to C:\Program Files (x86)\Arduino\libraries. The reason is that everything you save to C:\Program Files (x86)\Arduino is lost every time you update to a new version of the Arduino IDE. The libraries you install to the libraries subfolder of your sketchbook folder (C:\Users\Hp\Documents\Arduino\libraries in your case) will persist through IDE updates, so you don't need to worry about updates being a super disruptive process.

The other issue is this "shotgun" approach you take to installing libraries. Learn the correct way to install a library and do it only once for each library. Installing libraries to multiple places in the hopes that one of them will happen to be right is just silly, and bound to cause you problems in the future.