help with ATmega328 with MPU 6050 accelerometer sensor

Hi,

I'm new in this and I just got a ATmega328 and a Triple Axis acelerómetro y giroscopio MPU-6050 and I don't know nothing, these are what I have:

http://www.elecrow.com/wiki/index.php?title=Crowduino_v1.0

http://www.elecrow.com/wiki/index.php?title=MPU-6050

I have been reading but couldn't understand a lot so I want to know how to connect it right,

the A4 and A5 they go to Analog and GND to GND AND VCC to 3V3.

but in the board there is a switch 3V3_VCC_5V on the lower left corner and I don't know where it goes if in the 3V3 or VCC or 5V.

Please if anyone could help me, Thanks.

To be compatible with the Arduino set the switch on the board to 5V.

The 5V pin is 5V. The 3V3 pin is 3.3V

Connect the 3V3 pin to sensor board Vcc. Gnd to Gnd. A4 is SDA A5 is SCL

Run the i2c scanner, http://playground.arduino.cc/Main/I2cScanner Read this as a start, http://playground.arduino.cc/Main/MPU-6050 This is a full library, http://www.i2cdevlib.com/devices/mpu6050

AlexGR: but in the board there is a switch 3V3_VCC_5V on the lower left corner and I don't know where it goes if in the 3V3 or VCC or 5V.

The VCC is the power for the Atmega328. If press the switch to 3V3, the VCC ==3V3. If press the switch to 5V, the VCC==5V.

If VCC==3V3, when the output of the digital pins& the analog pins is high, the voltage is 3.3v. if VCC==5v, it is the same as Arduino.

Thanks, it was useful... :)

Erdin: Run the i2c scanner, http://playground.arduino.cc/Main/I2cScanner Read this as a start, http://playground.arduino.cc/Main/MPU-6050 This is a full library, http://www.i2cdevlib.com/devices/mpu6050

Hi,

I just run the sketch and it gives me error, I don't know what I have done wrong :(. Please help.

Which sketch ?
What error ?

Erdin: Which sketch ? What error ?

I run the MPU6050_raw.ino and MPU6050_DMP6.ino and it gave a lot of errors,

Like Error Compiling

56: error: no 'uint8_t MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)' member function declared in class 'MPU6050'
C:\Documents and Settings\Inf\Mis documentos\Arduino\libraries\MPU6050/MPU6050_9Axis_MotionApps41.h:769: error: no 'uint8_t MPU6050::dmpProcessFIFOPacket(const unsigned char*)' member function declared in class 'MPU6050'
C:\Documents and Settings\Inf\Mis documentos\Arduino\libraries\MPU6050/MPU6050_9Axis_MotionApps41.h:779: error: no 'uint8_t MPU6050::dmpReadAndProcessFIFOPacket(uint8_t, uint8_t*)' member function declared in class 'MPU6050'
C:\Documents and Settings\Inf\Mis documentos\Arduino\libraries\MPU6050/MPU6050_9Axis_MotionApps41.h:804: error: no 'uint16_t MPU6050::dmpGetFIFOPacketSize()' member function declared in class 'MPU6050'

and more...

It’s ready, now it can compile but now I have another problem,

when I put the Monitor Serial it shows me this

C´)c@·HJ°B?Ê%+CJK?´)j°KHJ¨`c?åH*?chJKcR)?Å`JH4`½ïHh?CH?Kc?)CÀKHJ cÀ?лÞnL?^BR CHJ?KCR	c??%ÓãÚó¥Bh(»?Ó³?^B£ChJc²)CZ??HJ?`Cx?SSû?ÓL?N²åHC?KK?´)c¸KHJ¬`?®BH?ChK¶JR)?Å`jHK`?ÏH¨*Ch?J
J´)C?KHJ¬`
jp?SS»?JBXBÅHCH`KHK¬`CXHJ
`
c

ºÏhH?cH?K
J?)J@êHKàc@âh+#hJJjR)k@JHJ:­`CÄHÐ*?cHKµCR)k?KJ`?c??+chJ
Jô)Bâ`kH`¼ç@Ð+»?KBXBH?cHK×LCR	b???J`?bhP»?K?cRJ²)c?kHJ¸`c¼åH*?ChJª
CR)?Å@KH:`?CH*CH`JHK¼CHÅh*chJK?CR)BÞs?SS»Þ×\?\BHHKËcR)ËÅ`JHh*cHKKCR)CZ@JjRbRÀ#?^ÚóµCR?åHc?KK
?´)c°KJC¶)b@JHK¼ChåH+hKK?CR)Ëå@kHK`¹ÏHT»?L?^BÑchËKj²)c`
HK`B?Ê?T»ÞÓ^?^bâHcHJK?´)B?JHJ`JÐh*chJKJ`KÏHh+chJ´
CR)gJHh+cJJ?CR)Kå`jHJ­`Cì`Ç?Óc?LbRHChJKJ
`?B@*CH?KJ²)bR??HK8C`Æh*HKJãÚó?ÏH\»ÞK¢çH*?ChJ´CR)½Å@JH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HK¨`C?åh+ó?ókÈJ`bÊH?chJJCRBR?̧?»??\?LBÆHCHJHJ¸`bÈÅh+hJJ×ãÚóCH»?Ó?NbHchK?JcRC??ÚÓóÚsCH?h*CJJ¹´)kx?%?¨`jP?åh+ã?sSÓLCR)?å@kHË`?Ï`H?chK?JJRC@HK
ÞK

:drooling_face:

Did the i2c scanner find the sensor ?

Are the MPU6050_raw.ino and MPU6050_DMP6.ino from the I2C dev lib ? http://www.i2cdevlib.com/devices/mpu6050

The examples use 115200 baud, so you must also set the serial monitor to that.

Thanks, the MPU6050_raw.ino worked :) but the MPU6050_DMP6.ino worked but it does nothing it stays stuck in:

Initializing I2C devices...
Testing device connections...
MPU6050 connection successful

Send any character to begin DMP programming and demo: 
Initializing DMP...
Enabling DMP...
Enabling interrupt detection (Arduino external interrupt 0)...
DMP ready! Waiting for first interrupt...

and I have a question, the measure of the accelerometer and gyroscope what value does it show???

The gyroscope shows the angles but what does the accelerometer shows???

Did you connect the INT output of the sensor to the pin 2 of the Arduino ?

The gyro shows how fast the sensor is rotating. Rotate it slow around an axis for a low value, rotate it fast around an axis for a high value.

The accelerometer show the gravity or acceleration force. If the sensor is moved in a direction (without rotation) slowly faster and faster, the output is a low value. If it is moved in a direction from slow to fast in a short time the output is a high value.
Hit the acceleromater on the table (a big change in speed) and you get a peak in the output value.

For more info, you could try wikipedia.

Ohh ok, thanks for the explanation :) now I've connected the Int output to pin 2 digital but I still have a problem

It shows me this

Initializing I2C devices...
Testing device connections...
MPU6050 connection successful

Send any character to begin DMP programming and demo: 
Initializing DMP...
Enabling DMP...
Enabling interrupt detection (Arduino external interrupt 0)...
DMP ready! Waiting for first interrupt...
$/YýBÕa
$/YýBÕ
a$/]ýHÕ
$/`ýJÕ
$/býMÕ
$/dýOÕ
$/fýRÕ
$/hýTÕ
$/jýWÕ
$/­ýÆÕa7

Did you use the defines to select which results to transmit ? If you use only the "OUTPUT_TEAPOT", you could see something like that.

I also have a MPU-6050 from Elecrow. I connect the VCC to 3V3, GND to GND, SCL to A5, SDA to A4. And I upload the demo code at the bottom of the wiki page. Open the serial monitor, set the rate as 38400. it works fine.

Initializing I2C devices...
Testing device connections...
MPU6050 connection successful
a/g:    -3236   -3336   12892   -113    -194    -212
a/g:    -3360   -3404   12860   -113    -256    -226
a/g:    -3344   -3336   12924   -109    -293    -225
a/g:    -3404   -3376   12820   -116    -379    -276
a/g:    -3108   -3336   12904   -179    12  -231
a/g:    -3396   -3404   12840   -224    297 -209
a/g:    -3428   -3520   12872   -227    524 -194
a/g:    -3372   -3416   12828   -242    726 -108
a/g:    -3484   -3428   12684   -251    684 -49
a/g:    -3372   -3352   12684   -226    706 -76
a/g:    -3380   -3348   12704   -153    604 -107
a/g:    -3260   -3512   12768   -85 694 -149
a/g:    -3376   -3444   12632   6   380 -392
a/g:    -3436   -3504   12768   118 164 -330
a/g:    -3380   -3352   12752   169 144 -346
a/g:    -3492   -3368   12696   181 247 -249
a/g:    -3328   -3380   12884   122 123 -176
a/g:    -3352   -3280   13176   59  34  -127
a/g:    -3344   -3336   13060   -69 189 -118
a/g:    -3384   -3228   12920   -191    392 -154
a/g:    -3356   -3236   12992   -281    534 -142
a/g:    -3336   -3216   12880   -280    583 -189
a/g:    -3388   -3208   12792   -313    581 -153
a/g:    -3536   -3380   12704   -178    117 -219
a/g:    -3496   -3464   12768   -117    137 -202
a/g:    -3480   -3384   12916   -69 104 -196
a/g:    -3684   -3336   12908   -109    78  -202
a/g:    -3648   -3368   13040   -188    140 -185
a/g:    -3456   -3268   12888   -162    112 -198
a/g:    -3500   -3280   12744   -193    65  -181
a/g:    -3540   -3340   12952   -234    250 -172
a/g:    -3584   -3320   12804   -216    151 -190
a/g:    -3472   -3364   12696   -156    -180    -273
a/g:    -3460   -3372   12772   -165    -149    -186
a/g:    -3500   -3356   12888   -142    -238    -179
a/g:    -3408   -3396   12844   -194    -97 -150
a/g:    -3404   -3404   12872   -195    141 -97
a/g:    -3368   -3284   12780   -179    46  -198