Interfacing Arduino Uno with MPU6050 Breakout board by Sparkfun


Hi!

Its time for me to post about my work. So as I mentioned in my abstract, I will be working with low-cost IMUs. Last week, we procured Sparkfun’s MPU6050 IMU. It costs around $40 ( shipping not included). You can view the IMU here.

Hardware Connections: The connections are pretty simple as MPU6050 follows I2C. So I connected VDD and VIO of MPU6050 to 3.3V from the Arduino board. Note that do not connect VIO to 5v of Arduino without using a resistor, else you will fry your MPU6050 board. Next, connect SDA ( Serial Data ) pin from MPU6050 board to Analog pin 4 and the SCL ( Serial Clock ) to Analog pin 5. Lastly connect Ground to your Arduino ground and your hardware connections are good to go! :D

Code: Since I am pretty lazy to write my code, I forked Jeff Rowberg’s awesome library. Yeah it works with an MSP too! You can install the library easily on the Arduino board. If you find some difficulty, you can follow these steps:

  • If you have freshly installed the Arduino IDE, I suggest you save a simple code. It can be any code.
  • Once you have saved, press Ctrl+K in Arduino IDE. It will open up the sketch folder. Usually it’s located in Home directory or Documents.
  • Go to the sketchbook folder -> libraries and copy the I2Cdev and MPU6050 folder from Jeff’s code.
  • Close and restart Arduino IDE. You should be able to see your library in the Examples folder.

I will attach a small screenshot of the sample program - MPU6050 s raw data.

Output of RAW data from MPU6050 Sparkfun's Breakout board on Arduino IDE.

Output of RAW data from MPU6050 Sparkfun’s Breakout board on Arduino IDE.

My next step will be to interface more than one MPU to the Arduino board and save their data. Once done with that, I can try to make some sense of the data which I will receive. Till then adios!

About these ads

12 comments

  1. […] I was experimenting with Arduino and SparkFun’s MPU6050, I came across the usual problem of Serial port being grayed out in Arduino IDE. Earlier I always […]

    1. SHAHEER SHAN · · Reply

      we are in need of the code for i2c interfacing using arduino…..could you please send it to us
      mail id : shaheer.shan@gmail.com

  2. […] Interfacing Arduino Uno with MPU6050 Breakout board by Sparkfun. […]

  3. […] is in continuation from my earlier post. As I mentioned, I will be connecting Multiple IMUs on the same I2C bus. Now the problem is this: […]

  4. Rido Agusta · · Reply

    I’ve tried to connect MPU6050 to Arduino but the led still red, can you help me?
    Thanks

    1. Hey!

      Are you using SparkFun’s MPU6050 breakout board?

  5. Hi there would you mind letting me know which webhost you’re working with? I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most. Can you recommend a good hosting provider at a honest price? Kudos, I appreciate it!

  6. […] mentioned in my earlier post, I am moving towards interfacing MPU6050 with BeagleBoard. MPU6050 operates at 3v3 and BeagleBoard […]

  7. makeitreal · · Reply

    Hi thanks so much for codes but I have some problems.When I run this program,I get
    C:\Users\Serbay\Documents\Energia\libraries\MPU6050\MPU6050.cpp: In member function ‘bool MPU6050::writeMemoryBlock(const uint8_t*, uint16_t, uint8_t, uint8_t, bool, bool)’:
    Energia\libraries\MPU6050\MPU6050.cpp:2988:87: error: ‘pgm_read_byte’ was not declared in this scope
    Energia\libraries\MPU6050\MPU6050.cpp: In member function ‘bool MPU6050::writeDMPConfigurationSet(const uint8_t*, uint16_t, bool)’:
    Energia\libraries\MPU6050\MPU6050.cpp:3057:44: error: ‘pgm_read_byte’ was not declared in this scope
    Energia\libraries\MPU6050\MPU6050.cpp:3076:100: error: ‘realloc’ was not declared in this scope
    Energia\libraries\MPU6050\MPU6050.cpp:3077:88: error: ‘pgm_read_byte’ was not declared in this scope
    Energia\libraries\MPU6050\MPU6050.cpp:3090:51: error: ‘pgm_read_byte’ was not declared in
    this scope.
    Do you know anything about this problem ?

  8. HI, add the i2cdevlib.h files in the MPU folder. I had the same issue.

  9. hi!
    I connect my arduino to the mpu 6050 in this way:
    VDD and VIO of MPU6050 to 3.3V from the Arduino board.
    SDA ( Serial Data ) pin from MPU6050 board to Analog pin 4.
    SCL ( Serial Clock ) to Analog pin 5.
    Ground – ground .
    as you write here…
    i try to use this libarary: https://github.com/jrowberg/i2cdevlib
    and i get zeros!!!
    what’s wrong!?!?!?
    thank you,
    reut.

  10. spookey · · Reply

    If some one is interested and wants a simple implementation of MPU6050, they can also have a look at this simple Library,
    http://hobbylogs.me.pn/?p=47
    It also explains angle calculation combining gyroscope and accelerometer measurements to avoid drift problem.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,915 other followers

%d bloggers like this: