natanaeljr / esp32-MPU-driver

ESP32 full library for all MPU6000 MPU6050 MPU6500 MPU9150 MPU9250 with SPI and I2C support and more.
MIT License
250 stars 67 forks source link

MPU6050 readings not working, values all 0 and mpud::MPU::whoAmI() error.... #9

Closed esperancaleonardo closed 6 years ago

esperancaleonardo commented 6 years ago

I'm trying to use your lib with an mpu6050 and an esp32 using esp-idf to flash data to my board, but having problems with comunication. All pins are defined correctly, pinned correctly but when I check the output it shows me "Pitch: +0.0 Roll: +0.0 Yaw: +0.0 " and the following error:

$ MPU Driver Example: Advanced E (2285) I2Cbus: [port:0, slave:0x68] Failed to read 1 bytes from register 0x75, error: 0x107 E (2285) MPU6050: func:uint8_t mpud::MPU::whoAmI() @ line:162, expr:"readByte(regs::WHO_AM_I, buffer)", error:0x107 E (2285) MPU6050: func:esp_err_t mpud::MPU::testConnection() @ line:143, expr:"lastError()", error:0x107 E (2295) example: Failed to connect to the MPU, error=0X107 Pitch: +0.0 Roll: +0.0 Yaw: +0.0 Pitch: +0.0 Roll: +0.0 Yaw: +0.0

and keeps showing this every 1sec. MPU6050 and ESP32 pin connections are

MPU6050 ---- ESP32 VCC ---- 5v GND ---- gnd SCL ---- 26 SDA ---- 14 INT ---- 17

I've googled a lot but no answer found! If ou could help me I'll be so gratefull, thx in advance...

natanaeljr commented 6 years ago

Which esp32 dev board are you using? Make sure you are connecting the I2C lines according to the GPIO numbers rather than PIN numbers. If you try the mpu_i2c example does it work?

esperancaleonardo commented 6 years ago

I'm using ESP-WROOM-32 in a ESP32 Core Board V2 / ESP32 DevKitC.

I'm using GPIO numbers correctly as I should.

Tested mpu_i2c with no success, same error ocurring... 1sec delay the same error is printed to monitor

natanaeljr commented 6 years ago

The error code 0x107 means I2C reading is timing out. So the esp32 might not be receiving from the MPU6050.

Try the following:

The scanner should show a device with address 0x68 or 0x69. If it does not show then you might have to re-check the wiring.

esperancaleonardo commented 6 years ago

All problems solved, nothing wrong with your library!!!

Problems were with my 2 MPU-6050 boards. I've tested 2 other new boards and you examples worked well with them.

Don't know why haven't tested the new boards yet! hahah

Thx by answering me, I'll close the issue by now!!!