I connected a MPU-6050 (GY-521) 3-Axis Accelerometer to the the I2C serial data bus on a Arduino Romeo v2.2; ground, 5v, SCL and SDA. (simple set up)
Using the code below I was able to read the sensor values on the serial monitor. Then I commented out the delay and uploaded the code again. I initially got values through the serial monitor for maybe 15 seconds, then the values all changed to -1 meaning I wasn't getting a signal. I tried running the I2C device scanner code and no devices were found. The senor still works when I try it on a different board. So I wonder if I could have damaged my board by not using a delay.
#include "Wire.h" //I2C lib
const int MPU_ADD = 0x68;// I2C address, if ADO pin is high address is 0x69
int16_t accelerometer_x, accelerometer_y, accelerometer_z;
int16_t gryo_x, gryo_y, gryo_z;
int16_t temp;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(MPU_ADD);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
}
void loop() {
// put your main code here, to run repeatedly:
Wire.beginTransmission(MPU_ADD);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_ADD, 14, true);
accelerometer_x = Wire.read()<<8 | Wire.read();
accelerometer_y = Wire.read()<<8 | Wire.read();
accelerometer_z = Wire.read()<<8 | Wire.read();
temp = Wire.read()<<8 | Wire.read();
gryo_x = Wire.read()<<8 | Wire.read();
gryo_y = Wire.read()<<8 | Wire.read();
gryo_z = Wire.read()<<8 | Wire.read();
Serial.print("aX = "); Serial.print(accelerometer_x);
Serial.print(" aY = "); Serial.print(accelerometer_y);
Serial.print(" aZ = "); Serial.print(accelerometer_z);
Serial.print(" temp = "); Serial.print(temp/340+36.53);
Serial.print(" gX = "); Serial.print(gryo_x);
Serial.print(" gY = "); Serial.print(gryo_y);
Serial.print(" gZ = "); Serial.println(gryo_z);
//delay(500);
}
The MPU-6050 is a 3.3V sensor, and although many of the modules come with a 5V to 3.3V regulator, there is usually no protection for the communications pins.
It is possible to destroy the sensor by exposing the sensor I2C pins to 5V, for example HIGH output pins on a 5V Arduino.
To be safe, use logic level shifters on the I2C lines. In the meantime, check for loose connections and poor solder connections or solder bridge shorts on the sensor module.
The Arduino Leonardo uses a USB interface and the baudrate is not really used for the serial monitor.
Without that delay, you are sending to much data to the serial monitor. The board might almost stop working, or you might create a lockup for the serial port which can not be solved in a normal way (only by burning a new bootloader).
With an Arduino Leonardo, you must use that delay.
The MPU-6050 does not need any delay, it is only to prevent an overload of the serial communication.
The other problem is the voltage mismatch on the I2C bus as jremington explained.
According to the schematic, the Romeo V2 does not have pullup resistors for SDA and SCL. That means that only the internal pullup resistors of the ATmega32U4 are connected to 5V. So you might be in luck and the MPU-6050 might not be destroyed... yet.
What about the wires between the Romeo V2 and the MPU-6050 module ? Are they short seperate wires or are you trying to use a cable ?