Hi,
I need to connect 4 MPU6050 from sparkfun and send acceleration and gyroscope data to my pc simultaneously. I am new to this i2C device so I dont really know how to play with the address thingy (as i only know with AD0 grounded it is 0x68 and AD0 connected to 3.3V it is 0x69).
I used multiplexer 74HC4051N to connect multiple MPU6050 together (as shown in the diagram). I do not really know my connection is correct or not (as i said I am really new in this field). So please advise on the hardware connection part.
Also I modified Jeff Rowberg arduino code and try to communicate with multiple MPU6050. However, all i get is only 0. The below is my arduino code:
//////////////////////////////////////////////////////////////////////////////////////////////////
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
MPU6050 accelgryo;
int16_t ax, ay, az, gx, gy, gz, ax1, ay1, az1, gx1, gy1, gz1;
//ASSIGN DIGITAL PINS (MUX)
int S0 = 3;
int S1 = 2;
int S2 = 1;
unsigned long time;
void out1()
{
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
digitalWrite(S2, LOW);
}
void out2()
{
digitalWrite(S0, LOW);
digitalWrite(S1, HIGH);
digitalWrite(S2, LOW);
}
void setup()
{
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
Serial.begin(36400);
}
void loop()
{
time=millis();
out1();
accelgryo.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
out2();
accelgryo.getMotion6(&ax1, &ay1, &az1, &gx1, &gy1, &gz1);
Serial.print("DATA,TIME,");
Serial.print(time);
Serial.print(",");
Serial.print(ax);
Serial.print(",");
Serial.print(ay);
Serial.print(",");
Serial.print(az);
Serial.print(",");
Serial.print(gx);
Serial.print(",");
Serial.print(gy);
Serial.print(",");
Serial.print(gz);
Serial.print(",");
Serial.print(ax1);
Serial.print(",");
Serial.print(ay1);
Serial.print(",");
Serial.print(az1);
Serial.print(",");
Serial.print(gx1);
Serial.print(",");
Serial.print(gy1);
Serial.print(",");
Serial.println(gz1);
delay(10);
}
//////////////////////////////////////////////////////////////////////////////////////////////
Can anyone advise what went wrong software and hardware, and how can I modify it?
Thank you very much.