Hi,
I wanted to use my MPU6050 with my ESP32 Devkit V1 from Doit.
I would like to use it with this library.
I tested it successfully with my Arduino Nano but the ESP32 doesn't get correct values.
I used this sketch (slightly changed version of the GetAllData example from the lib):
#include <MPU6050_tockn.h>
#include <Wire.h>
MPU6050 mpu6050(Wire);
long timer = 0;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
}
void loop() {
mpu6050.update();
if(millis() - timer > 1000){
Serial.println("=======================================================");
Serial.print("temp : ");Serial.println(mpu6050.getTemp());
Serial.print("accX : ");Serial.print(mpu6050.getAccX());
Serial.print("\taccY : ");Serial.print(mpu6050.getAccY());
Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ());
Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX());
Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY());
Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ());
Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX());
Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY());
Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX());
Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY());
Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ());
Serial.print("angleX : ");Serial.print(mpu6050.getAngleX());
Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY());
Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ());
Serial.println("=======================================================\n");
timer = millis();
}
}
And get always this output:
========================================
calculate gyro offsets
DO NOT MOVE A MPU6050...
Done!!!
X : 0.00
Y : 0.00
Z : 0.00
Program will start after 3 seconds
===============================================================================================
temp : 36.51
accX : 0.00 accY : 0.00 accZ : 0.00
gyroX : 0.00 gyroY : 0.00 gyroZ : 0.00
accAngleX : 0.00 accAngleY : 0.00
gyroAngleX : 0.00 gyroAngleY : 0.00 gyroAngleZ : 0.00
angleX : 0.00 angleY : 0.00 angleZ : 0.00
=======================================================
When I run the "same sketch" on the Nano I get this output:
========================================
calculate gyro offsets
DO NOT MOVE A MPU6050...
Done!!!
X : -3.22
Y : 2.46
Z : 0.60
Program will start after 3 seconds
===============================================================================================
temp : 24.79
accX : 0.19 accY : -0.00 accZ : 0.86
gyroX : -0.02 gyroY : 0.07 gyroZ : -0.08
accAngleX : -0.15 accAngleY : -12.40
gyroAngleX : -0.15 gyroAngleY : 0.67 gyroAngleZ : -0.75
angleX : -0.53 angleY : -11.37 angleZ : -0.75
=======================================================
I even tried it with pullup-resitors but then an I2C scanner couldn't find the MPU6050 anymore.
Without the resistors the I2C scanner found the MPU6050.
I have no clue how to fix this problem.
Could You please help me?