Communication with MPU6050 failed!

Hi, Im trying to connect ESP32 Wroom to MPU6050 but with no luck.

the following to the error log upon upload

[16:18:46][C][wifi:318]:   DNS1: 192.168.1.2
[16:18:46][C][wifi:319]:   DNS2: 0.0.0.0
[16:18:46][C][i2c:028]: I2C Bus:
[16:18:46][C][i2c:029]:   SDA Pin: GPIO21
[16:18:46][C][i2c:030]:   SCL Pin: GPIO22
[16:18:46][C][i2c:031]:   Frequency: 50000 Hz
[16:18:46][I][i2c:033]: Scanning i2c bus for active devices...
[16:18:46][I][i2c:040]: Found i2c device at address 0x19
[16:18:46][I][i2c:040]: Found i2c device at address 0x1E
[16:18:46][C][logger:185]: Logger:
[16:18:46][C][logger:186]:   Level: DEBUG
[16:18:46][C][logger:187]:   Log Baud Rate: 115200
[16:18:46][C][logger:188]:   Hardware UART: UART0
[16:18:46][C][mpu6050:085]: MPU6050:
[16:18:46][C][mpu6050:086]:   Address: 0x18
[16:18:46][E][mpu6050:088]: Communication with MPU6050 failed!
[16:18:46][C][mpu6050:090]:   Update Interval: 60.0s
[16:18:46][C][mpu6050:091]:   Acceleration X 'MPU6050 Accel X'
[16:18:46][C][mpu6050:091]:     Unit of Measurement: 'm/s²'
[16:18:46][C][mpu6050:091]:     Accuracy Decimals: 2
[16:18:46][C][mpu6050:091]:     Icon: 'mdi:briefcase-download'

i have tried Address: 0x18 0x19 0x1E

my Yaml code


i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: True
sensor:
  
  - platform: mpu6050
    address: 0x18
    i2c_id: bus_a
    accel_x:
      name: "MPU6050 Accel X"
    accel_y:
      name: "MPU6050 Accel Y"
    accel_z:
      name: "MPU6050 Accel z"
    gyro_x:
      name: "MPU6050 Gyro X"
    gyro_y:
      name: "MPU6050 Gyro Y"
    gyro_z:
      name: "MPU6050 Gyro z"
    temperature:
      name: "MPU6050 Temperature"

The hardware was working fine using Arduino IDE C++ coding
Your help would be much appreciated

did you try without defining the address? Its optional and defaults to 0x68

Thank you.
i just tried that with the same error

  Frequency: 50000 Hz
[17:56:04][I][i2c:033]: Scanning i2c bus for active devices...
[17:56:04][I][i2c:040]: Found i2c device at address 0x19
[17:56:04][I][i2c:040]: Found i2c device at address 0x1E
[17:56:04][C][logger:185]: Logger:
[17:56:04][C][logger:186]:   Level: DEBUG
[17:56:04][C][logger:187]:   Log Baud Rate: 115200
[17:56:04][C][logger:188]:   Hardware UART: UART0
[17:56:04][C][mpu6050:085]: MPU6050:
[17:56:04][C][mpu6050:086]:   Address: 0x68
[17:56:04][E][mpu6050:088]: Communication with MPU6050 failed!
[17:56:04][C][mpu6050:090]:   Update Interval: 60.0s

just spotted that the i2c scanning shows TWO i2c devices, there is only ONE physically connected, any ideas?

[19:10:29][I][i2c:033]: Scanning i2c bus for active devices...
[19:10:29][I][i2c:040]: Found i2c device at address 0x19
[19:10:29][I][i2c:040]: Found i2c device at address 0x1E

I havent seen such a thing. Maybe some other users would be knowing. I have seen other posts with the same issue. Maybe you should try tamsota. But you will have to compile your own firmware. Hope you know about it.

https://tasmota.github.io/docs/MPU-6050/

If you want I can share a tasmota.bin file that I tried to compile for MPU-6050… but dont know if that works.

if you could share that BIN file that would be much appreciated.
Is tasmota able to control 4 relays too.
is it possible to include the " Digital Motion Processor Enabled"
i have built a 1Kw solar panel sun tracker that moves on two axis’s, X suns horizon angle and Y suns azimuth (from 90 degrees to 270 degrees.
basically i need to be able to read the mpu6050 compare with an API response, then use 4 relays to control two linear actuators.
Many thanks

Yes , it can but make sure you select the best pins with esp. If it was esp8266, the below is the list of best pins for output.

Download bin from this Send Anywhere

If this doesnot work you can compile it yourself, the tasmota webpade has all the docs on it.

Finally after much trying I have found the problem and solution.
Its the MUP6050 (GY521)
I have 10 x GY521 units and only ONE works. All units brand new, using esphome.

So if anyone else has this problem, try this solution; buy 10x units and throw 9 away.

There must be a bug in the MPU6050 library for ESPHome. Maybe it depends on internal MPU6050 registers that are not being reset properly.

Edit: Continuing the discussion here: MPU6050 component error "Communication with MPU6050 failed!" · Issue #2279 · esphome/issues · GitHub