jrowberg / i2cdevlib

I2C device library collection for AVR/Arduino or other C++-based MCUs
http://www.i2cdevlib.com
3.95k stars 7.51k forks source link

esp-idf mpu6050 example not working #696

Open brand17 opened 2 years ago

brand17 commented 2 years ago

I am running the standard example https://github.com/jrowberg/i2cdevlib/blob/master/ESP32_ESP-IDF/main/example.cpp. I only had to swap PIN_SDA and PIN_CLK to make it working (based on https://www.instructables.com/ESP32-Internal-Details-and-Pinout/).

The code doesn't enter into the following block because the bit 1 is always zero.

    } else if (mpuIntStatus & 0x02) {

What could be a reason?

I've checked that DMP initialized correctly and enabled.

I tried to check the zero bit instead (based on https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf (page 28)) - but I am getting wrong sensor orientation (angles and quarternion looking like random figures).

I also ensured that the sensor is ok: the Arduino example https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050/examples/MPU6050_DMP6 works like a charm from Arduino IDE.

I compared the both examples and found out that the Arduino one doesn't check this register (INT_STATUS) at all. I tried to remove use of this register - but still have unstable quarternion values.

But I checked that the bit 1 works as expected in Arduino example.

Please note that I don't use the sensor interrupt pin - I don't see use of that in the example (interrupt PIN or smth like that).

brand17 commented 2 years ago

As far as I understand - there were errors in the firmware (dmpMemory block). I've prepared a patch here - https://github.com/jrowberg/i2cdevlib/pull/698