Go Down

Topic: Wire MPU6050 (cheap eBay breakoutboard) to Arduino MEGA 1280 (Read 3 times) previous topic - next topic

EliteTUM

Hi everyone,

I tried using a MPU6050 I got quite cheap from eBay with my Arduino MEGA 1280. Unfortunately, I can't get it running. I don't event get a proper connection.

I attached a picture of the breakout-board. For those who can't see it, the pins are:
VCC
GND
SCL
SDA
XDA
XCL
AD0
INT

I asked the seller and he gave me the following advice for wiring it all together:






MPU6050 breakoutboard Arduino MEGA 1280
VCC<->3V3
GND<->GND
SCL<->ANALOG IN A5
SDA<->ANALOG IN A4


I also attached the Code he gave me (RAR-File). For those who can not open it, try this Link. The Sketch-File looks like this:

Code: [Select]
// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
//     2011-10-07 - initial release

/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2011 Jeff Rowberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "MPU6050.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

#define LED_PIN 13
bool blinkState = false;

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    Wire.begin();

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);

    // initialize device
    Serial.println("Initializing I2C devices...");
    accelgyro.initialize();

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
}

void loop() {
    if (accelgyro.testConnection()) {
        // read raw accel/gyro measurements from device
        accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
   
        // these methods (and a few others) are also available
        //accelgyro.getAcceleration(&ax, &ay, &az);
        //accelgyro.getRotation(&gx, &gy, &gz);
   
        // display tab-separated accel/gyro x/y/z values
        Serial.print("a/g:\t");
        Serial.print(ax); Serial.print("\t");
        Serial.print(ay); Serial.print("\t");
        Serial.print(az); Serial.print("\t");
        Serial.print(gx); Serial.print("\t");
        Serial.print(gy); Serial.print("\t");
        Serial.println(gz);
   
        // blink LED to indicate activity
        blinkState = !blinkState;
        digitalWrite(LED_PIN, blinkState);
    }
}


I slightly changed the loop()-Function here so it won't flood my SerialMonitor. Nevertheless, I always get the error

Quote
MPU6050 connection failed


Where did I go wrong? Is it simply my wiring, the code, or both?

I'm new to I2C-Usage on Arduino, so sorry for this (maybe) rather simple problem. Any help is appreciated  a lot; thanks in advance!

Regards!

teckel

My guess is that your breakout board doesn't include voltage regulators for the signal pins.  Therefore, you're feeding 5v to the sensor over the signal pins and probably fried it.  Get another one, but not just a breakout board but one with voltage regulators.

Tim
Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

EliteTUM

Thanks for the hint. I checked back with the seller and he assured me this should work without special voltage regulators. I'll try to test it with another Arduino.

Nantonos


I asked the seller and he gave me the following advice for wiring it all together:






MPU6050 breakoutboard Arduino MEGA 1280
VCC<->3V3
GND<->GND
SCL<->ANALOG IN A5
SDA<->ANALOG IN A4



That is wrong (it is the right answer for an Arduino Uno). One Arduino Mega1280 and Mega2560 the SCL is on pin 21 and the SDA is on pin 20.

Nantonos

#4
Nov 09, 2012, 09:23 am Last Edit: Nov 09, 2012, 09:27 am by Nantonos Reason: 1

My guess is that your breakout board doesn't include voltage regulators for the signal pins.  Therefore, you're feeding 5v to the sensor over the signal pins and probably fried it.  Get another one, but not just a breakout board but one with voltage regulators.


(Assuming you mean logic-level converters, not voltage regulators). Yes - looking at this page it clearly says the operting voltage is 2.375V-3.46V. In other words this expects 3V3 not 5V0 logic.

So it should be connected via an I2C-capable logic level converter.

On the other hand, since the break-out boad was connected to A4 and A5 which were doing nothing (on a Mega1280) the board is maybe not fried ... yet. And on the third hand, this datasheet says (on page 20):

Quote
Supply Voltage, VDD   -0.5V to +6V

Go Up