Multiplexing 3 MPU6050 (i2c sensors)

I’m using three InvenSense MPU-6050 to measure angles. Since the MPU6050 has only addresses of 0x68 and 0x69(selected by AD0) on the i2c bus, I decided to attempt to connect the multiple sensors to arduino using a 74HC4051 multiplexer. The part i intend to multiplex is the AD0 pins of each sensor. I have attached a schematic of the connection i have at the moment. I’m having a problem altering the sketch to include the multiplexer loops.
Also, is the connection for multiplexing correct in the image attached? or should i multiplex SDA or SCL pins?

circuitmir: The part i intend to multiplex is the AD0 pins of each sensor.

That circuit won't multiplex anything. Also there's no ground connection to the 4051 that I can see.

I have attached a schematic of the connection i have at the moment.

That's not a schematic - it's just another crap Fritzing diagram. Whatever happened to real schematic diagrams? They're much more useful, easier to read and contain far more information. Forget the Fritzing junk.

Also, is the connection for multiplexing correct in the image attached?

No.

or should i multiplex SDA or SCL pins?

Yes, I'd do both.

You might have trouble with the "INT" pins/handling, too. Also FIFO buffer overruns, if you're not careful.

  1. No need to mux SCL/SDA. Use three output lines to the three A0 pins - hold 2 high, bring the third and talk to that chip using the A0=0 address.
  2. Does that module want to see 3.3V or 5V level signals?
  3. I don't see any I2C pullup resistors. The internal pullups on A4/A5 are not likely to be sufficient to make good enough signal switching from low to high.

CrossRoads: 1. No need to mux SCL/SDA. Use three output lines to the three A0 pins - hold 2 high, bring the third and talk to that chip using the A0=0 address. 2. Does that module want to see 3.3V or 5V level signals? 3. I don't see any I2C pullup resistors. The internal pullups on A4/A5 are not likely to be sufficient to make good enough signal switching from low to high.

Of course. Duh. I was looking at it wrongly. My bad. :(

But will the INT pins be a problem?

Edit: The GY521 modules usually have onboard 3.3V pullup resistors, though, (or at least mine do - 2K2 resistors), so additional pullups shouldn't be needed. I disabled the internal pullups in "twi.c" when using those modules.

And the circuit still won't work as posted. Pin 3 on the 4051 needs to be connected to ground, (as well as it's Vss pin), and pullups are needed on the MPU6050 address pins, so that the selected pin is pulled low when addressed to select 0x68, and the two that aren't selected are high and have 0x69 as their address. (I think I'm right with this.)

May need a pullup on the INT line, and have to query them to see who created it.
Could also have a separate INT for each one using PCINT.
I don’t see need for the 4051 at all.

CrossRoads: I don't see need for the 4051 at all.

Good point. It doesn't save any pins.

The INT issue might need some thought, as you mention. Some library mods might be needed to accommodate using multiple INTs, if a library is being used. Also, FIFO buffer overruns still need to be considered when running multiples of this chip. There won't be much time to do other stuff. I found this out the hard way, when also using the onboard DMP.

The image I posted is not a complete circuit I know that. The GND of the 4051 is connected to ground. The reason behind the post is that I'm unsure how to connect the AD0 pins in order to multiplex the address.

My idea was connecting the AD0 pins to pin 3 of the 4051. Using that to keep one at address 0x69 and record data, while having the other two at 0x68.

I'm a beginner at arduino and electronics, so bare with me if my circuit jargon isn't on point! I'd appreciate the help

circuitmir: My idea was connecting the AD0 pins to pin 3 of the 4051. Using that to keep one at address 0x69 and record data, while having the other two at 0x68.

What, all AD0 pins 3 together, to pin 3? How would that work?

If you do use the 4051, you'd have to do it the other way around. Make pin 3 of the 4051 high, then connect 3 of the multiplexed outputs to the three MPU6050 module address pins, so that when you address each, they're pulled high. (That's if you want to use 0x69 as the active address.)

There's something else you need to consider too - the MPU6050 is a 3.3V chip, so you might not be able to connect the address pins to 5V. You might need to use 3.3V for this purpose. ie Connect 3.3V to pin 3 of the 4051.

If you can apply 5V to the address pins, then as CrossRoads pointed out, you don't need the 4051 at all for address multiplexing. Since it uses three pins for addressing, you might as well just connect three Arduino pins to the three MPU6050 address inputs and control them directly.

And don't forget there's still the INT pins to consider.

The first thing to do is find out if the MPU6050 modules address inputs can handle 5V, then go from there, (while thinking about how to handle the "INT" aspect).