Hallo liebes Forum,
ich möchte mit dem Lagesensor MPU 6050 den aktuellen Winkel auslesen.
Jetzt habe ich mit dem I2C-Scanner zwar die adresse auslesen können, (0x68), wenn ich dann allerdings den Sketch von AZ-Delivery Imu_zero lade, bekomme ich im seriellen Monitor die Meldung connection failed.
Könnt ihr mir bitte sagen, was ich da falsch mache? es sind die standardsketche aus dem E-Book unverändert.

LG Fridold

The code below works fine to measure tilt angles.

bekomme ich im seriellen Monitor die Meldung connection failed.

You may need to add 3.3K pullup resistors from SDA and SCl to 3.3V. They are not present on many of the cheap MPU-6050 modules from China.

/ minimal MPU-6050 tilt and roll (sjr)
// works perfectly with GY-521, pitch and roll signs agree with arrows on sensor module 7/2019
// tested with eBay Pro Mini, **no external pullups on SDA and SCL** (works with internal pullups!)
const int MPU_addr1 = 0x68;
float xa, ya, za, roll, pitch;

void setup() {

  Wire.begin();                                      //begin the wire communication
  Wire.beginTransmission(MPU_addr1);                 //begin, send the slave adress (in this case 68)
  Wire.write(0x6B);                                  //make the reset (place a 0 into the 6B register)
  Wire.endTransmission(true);                        //end the transmission

void loop() {

  Wire.write(0x3B);  //send starting register address
  Wire.endTransmission(false); //restart for read
  Wire.requestFrom(MPU_addr1, 6, true); //get six bytes accelerometer data

  xa = << 8 |;
  ya = << 8 |;
  za = << 8 |;
// formula from
  roll = atan2(ya , za) * 180.0 / PI;
  pitch = atan2(-xa , sqrt(ya * ya + za * za)) * 180.0 / PI; //account for roll already applied

  Serial.print("roll = ");
  Serial.print(", pitch = ");

Hi folks,

thanks for your answers.

the idea to attach two pull up do not change anything. i got the same response, connection......

@ jremington : your code works fine , so i wanna thank you very much.

best regards fridold