Multiple mpu6050 with 4051 Mux

I am trying to connect 4 mpu6050 with arduino mega along i2c, i am using 4051 IC to get different readings from sensors since there are only two addresess 068 and 069 and only two sensors can be connected. Therefore 4051 is necessary for more sensors than two.

Since 0*69 address is used when AD0 pin is high therefore i have connected different pins to arduino and i make the pins high just before taking the readings from all 4 mpu6050 seperately but i am not able to get all 4 readings. i am able to get just one reading

My code is attached with the serial monitor result.

Please help

multiple_mpu_testing.ino (6.87 KB)

mega has plenty of I/O pins.. u might create ur own I2C on several unused pins and avoid adding the extra mux hardware..its really not needed

How can we make other i/o pins i2c? i guess they are dedicated at a4 and a5 in mega..

Sorry a4 and a5 in uno and 20 ,21 in mega

I2C u can roll ur own.. also i am sure if u search, u will find I2c library function..
I made my own I2C routine 20yrs ago on a PIC..

found it for u..
softI2C.h

http://playground.arduino.cc/Main/SoftwareI2CLibrary

just download and include this library and u can call I2C on any set of pins u need to..

never add hardware when u can already just use the hardware u already have..