I use a Arduino Uno to connect two MPU6050,when I start, the monitor showed both two sensors connect
successfully, and start running. But just only working 3 ~ 5 seconds, and then arduino stopped.
I push the reset bottom on arduino, it starts working again, but only last for few seconds, so what wrong is
my project.
Here is my circuit Arduino-MPU6050
5V-VCC1-VCC2-(AD01 or AD02)
GND-GND1-GND2
PIN5-SCL1-SCL2
PIN$-SDA1-SDA2
What does the I2C scanner say? Different addresses found?
Here is my code:
#include "I2Cdev.h"
#include "MPU6050.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
MPU6050 accelIC1(0x68);
MPU6050 accelIC2(0x69);
int16_t ax1, ay1, az1;
int16_t ax2, ay2, az2;
#define OUTPUT_READABLE_ACCELGYRO
void setup() {
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
Serial.begin(38400);
// initialize device
Serial.println("Initializing I2C devices...");
accelIC1.initialize();
accelIC2.initialize();
// verify connection
Serial.println("Testing device connections...");
Serial.println(accelIC1.testConnection() ? "MPU6050 #1 connection successful" : "MPU6050 #1 connection failed");
Serial.println(accelIC2.testConnection() ? "MPU6050 #2 connection successful" : "MPU6050 #2 connection failed");
}
void loop() {
accelIC1.getAcceleration(&ax1, &ay1, &az1);
accelIC2.getAcceleration(&ax2, &ay2, &az2);
#ifdef OUTPUT_READABLE_ACCELGYRO
// display tab-separated accel x values
Serial.print("a:\t");
Serial.print(ax1); Serial.print("\t");
Serial.println(ax2);
#endif
#ifdef OUTPUT_BINARY_ACCELGYRO
Serial.write((uint8_t)(ax1 >> 8);
Serial.write((uint8_t)(ax2 >> 8);
#endif
}