0

I have an Arduino Mega 2560 that I need to connect 4 MPU 6050/Gy 521's to.

I found some resources on the Mega and Uno, however I'm having trouble piecing them together.

This resource gives great detail for connecting a single MPU to a mega. http://dummyscodes.blogspot.com/2014/07/mpu6050-gy-521-breakout-arduino-mega.html

This resource gives a trick for connecting multiple to an UNO. https://playground.arduino.cc/Main/MPU-6050

My problem is that the wiring for the Uno and Mega are different. The resource I have for the UNO describes using the MPU AD0 (output) connecting it to different output pins for each MPU. The resource talking about the MEGA doesn't even use the AD0, and uses INT but I'm not sure if I can use the same concept.

Plus, I still don't actually understand how to connect/what other pins to use for the other 4.

I'm pretty new to Arduino, definitely new to anything with wiring.

Please help! I'm really confused about using multiple together, and about how to properly wire them.

1

MPU-6050 uses I2C for comm's, yes? Connect all the SCLs in parallel to the Mega with a 4.7K, or 3.3K, pullup resistor. Same for the SDAs. I2C is D20, D21 (or D21, D22) on the Mega.

The MPU-6050 has an A0 pin to select from one of two addresses, let's call them Add0 and Add1 for simplicilty. Connect each MPU-6050 A0 pin to a unique Mega pin. When none are being addressed, have each Mega output high. When one MPU-6050 is to be accessed, take that device's A0 pin low and communicate with it using Add0. The other's will be looking for communications at Add1 and thus will not respond.

If the MPU6050 is a 3.3V device, then you should also remove the pullup resistor network package on the Mega that pulls SCL/SDA to 5V. There are 2 pullups in a very little 8-pin package, the other 2 are not used. Connect the 3.3K or 4.7K pullup resistors discussed above to 3.3V.


This is the part, RN1, on the Mega R3 board. It may not be marked as such on the board. Remove it, or cut the traces next to the pad legs, one on the left side (connects to pin 3), one on the top (connects to pin 2). enter image description here enter image description here

  • I didn't know about the pullup resistor package on the Mega's I2C bus. Is that meant to be removable/replaceable, or do you have to snap it off destructively? – Duncan C Apr 8 at 21:47
  • I wouldn't snap it off, but it would come without too much difficulty with a soldering iron. – CrossRoads Apr 9 at 11:08
0

CrossRoads' answer using the address selection pin on your MPU modules is excellent. It does tie up a GPIO line for each MPU you want to address however.

(If you are using a Mega 2560 this might not be an issue since they have tons of GPIO lines.)

You could also get a I2C addressing multiplexer. Adafruit and Sparkfun both offer them Example: https://www.adafruit.com/product/2717?gclid=EAIaIQobChMItYnah7zB4QIVAoTICh1JlAk3EAQYASABEgK7hvD_BwE

That one will multiplex up to 8 I2C devices with the same address, and doesn't require any additional pins. You send a single I2C command to it to select one of your 8 devices.

I don't know if anybody makes an I2C multiplexer that also does voltage conversion. Seems like that would be handy.

0

CrossRoads answer using the address selection pin on your MPU modules is excellent. It does tie up a GPIO line for each MPU you want to address however.

You could also get a I2C addressing multiplexer. Adafruit and Sparkfun both offer them Example: https://www.adafruit.com/product/2717?gclid=EAIaIQobChMItYnah7zB4QIVAoTICh1JlAk3EAQYASABEgK7hvD_BwE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.