Hi,
i read the MPU6050 without the MPU6050-lib (based on the lib):
Initialisation:
void initMPU6050() {
Serial.print("Init MPU6050 "); // MPU6050 initialisieren
SetConfiguration(0x6B, 0x80) ; // Powermanagement aufrufen Sensor schlafen und Reset, Clock wird zunächst von Gyro-Achse Z verwendet
delay(500);
SetConfiguration(0x6B, 0x03); // Powermanagement aufrufen Sleep beenden und Clock von Gyroskopeachse X verwenden
delay(500);
SetConfiguration(0x1A, 0x00); // Konfigruation aufrufen: Default => Acc=260Hz, Delay=0ms, Gyro=256Hz, Delay=0.98ms, Fs=8kHz
Serial.println(".. ready!");
}
void SetConfiguration(byte reg, byte setting) {
Wire.beginTransmission(IIC_ADRESS_ACCELGYRO); // Aufruf des MPU6050 Sensor
Wire.write(reg); // Register Aufruf
Wire.write(setting); // Einstellungsbyte für das Register senden
Wire.endTransmission();
}
Read the sensor:
void readMPU6050(byte accelgyroCalibrated) {
byte i;
int accelGyroUFilt[6];
byte result[14];
Wire.beginTransmission(IIC_ADRESS_ACCELGYRO); // Aufruf des MPU6050 Sensor
Wire.write(0x3B); // Anfangsadresse von Beschleunigungssensorachse X
Wire.endTransmission();
Wire.requestFrom(IIC_ADRESS_ACCELGYRO, 14); // 14 Bytes kommen als Antwort
for(i=0;i<14;i++) {result[i] = Wire.read();} // Bytes im Array ablegen
accelGyroUFilt[0] = ((result[0]<<8) | result[1]); // ax
accelGyroUFilt[1] = ((result[2]<<8) | result[3]); // ay
accelGyroUFilt[2] = ((result[4]<<8) | result[5]); // az
accelGyroUFilt[3] = ((result[8]<<8) | result[9]); // gx
accelGyroUFilt[4] = ((result[10]<<8) | result[11]); // gy
accelGyroUFilt[5] = ((result[12]<<8) | result[13]); // gz
}
This works quite fine ... And you don't have to include any libs beyond Wire.h
Philipp