MPU-6050 FIFO problems

I have my MPU-6050 working fine using the code from the arduino playground from Krodol, but I can't get the FIFO enabled and working. Does anyone have some example code they could share?

The FIFO appears to work fine when I use the DMP example, but that seems to be just a black box. I want to measure the z-axis of the gyro directly. This works using Krodol's example code, and I can read and write to the configuration registers. I can get readings directly from the sensor registers, but when I read from FIFO I get nothing. Also the FIFO counter reports 0 (I read it in the proper order, COUNTH, then COUNTL). I have scoured the register map for any setting that my affect the FIFO. I have set the proper bits in the FIFO_EN, and USER_CTRL registers. I have set the clock source to internal 8kHz as well as various gyro PLL clocks. I still see no sign of data on the FIFO. Can anyone shed some light? Thanks!

The code by Jeff Rowberg (using dmp) is the only good code for that sensor. You should study his code how to use the fifo.
http://www.i2cdevlib.com/

Did his code run ? With interrupt and fifo ?

Is there an example with raw gyro data ?
http://www.i2cdevlib.com/devices/mpu6050
Github is down at the moment, so I can't check the examples.

That code works fine with both DMP and RAW. It's not obvious in the code, though, how to get FIFO working. In the DMP example, the FIFO works, but the code is full of unknown functions and large blocks of byte codes that make it almost impossible to decipher. Because it's almost a black box, it's impossible to customize for my application.

I want to use the RAW mode, which is easier to follow and configure, but it doesn't use the FIFO buffer. What I want is a clear example of working code that uses the FIFO, but not in DMP mode.

I don't know if that exists.

In the code by Jeff Rowberg, the function "setZGyroFIFOEnabled()" enables the raw Z-axis gyro value to be placed into the FIFO. Perhaps that is something to start with.

Hello,
I have the following problem. Are built on a breadboard.
Arduino MEAG 2560
MPU6050 on 5V
SDA and SCL 4,7k Pullup to 3.3V
INT connect to PIN 2
ADO to GND
Bauderate 19200 or 115000
BMP085 → 5V
HMC5883L → 3.3V I2C Not connected to MPU6050
All voltages from the Arduino.

MPU6050 example Raw and DMP.

The values ypr are usually OK. Meanwhile, a FIFO overflow is reported. I have checked the contacts on the breadboard. They’re OK, I guess.

while (!mpuInterrupt && fifoCount < packetSize)
{
// other program behavior stuff here
Test =+1; ← This statement is not executed.
}

I’ve been trying for a very long time to find the error, would be grateful for any help. I will write this in the German forum too.
Best regards
Willi

MPU5060_Plot.png

if you are trying to increment the variable "test"

try

test += 1 ;

You might have your plus sign character and your equals sign character in the wrong order.

Thanks for the feedback. That's just a typo in this thread.
LG
Willi

The problem of “FIFO overflow” is solved. I have the HMC5883L directly connected to the MPU6050. Unfortunately, the I2C scanner does not find the HMC5883L (0x1E). Does anyone have a tip?

Willi

It would have been nice to share your solution :wink:

@NATO, I have been struggling with a similar problem and as you mentioned that you started with Krodol's code, you may have run into the same issue.

I also started with Krodol's code and the symptoms were the same as yours. This code, however, works:

I spent countless hours to figure out, why the code based on Krodol's code does not work and at the end, the solution was ridiculously trivial. Krodol reuses the MPU6050_FIFO_EN macro, first as a register:

#define MPU6050_FIFO_EN 0x23 // R/W

and then as a bit:

#define MPU6050_FIFO_EN MPU6050_D6

This means that if you innocently try to modify Krodol's code to handle the FIFO, the key FIFO_EN register's address will be incorrect. The error is very hard to notice as the first definition is correct.