MPU6050 data freezing on ESP32

I am having a problem with a data logger project with the MPU6050 FIFO data freezing or no longer updating.

The hardware is a Heltec ESP32 development board, and a MPU6050 accel/gyro board. I do not know who makes the MPU6050 board. There is also a uBlox GPS module

The MPU6050 initializes and begins outputting data just fine. But after, what seems to be a random period, the data freezes and stops changing even if motion is present with the MPU6050 board.

The MPU6050 library is by Electronic Cats GitHub - ElectronicCats/mpu6050: MPU6050 Arduino Library
This library was not reading valid data from the MPU6050

The developers at Electronic Cats suggested I post on the github for jrowberg i2cdev since thris library is based on that code.

I was told by Homer Creutz that the read FIFO bytes in the Electronic Cats library is flawed. He provided a function that was pasted into my code.

However the data now freezes after a period and stops updating. I have not heard from anyone on github for a while. But he suggested I post here

Any help is greatly appreciated

Serial monitor output of MPU6050 data attached

I tried to paste in the code using the </> button but got the error
The message has the following error or errors that must be corrected before continuing:
The message exceeds the maximum allowed length (9000 characters).

I am attaching the code as an attachment

Monitor-Upload.txt (7.68 KB)

ESP32-GPS-Accel_to_SD-NEW.ino (9 KB)

If you get rid of all the other code (only MPU6050), does it work then? If it doesn't, post a complete wiring diagram of your setup!

When starting with Arduino, try to stay in the bright open plaza.
At Adafruit they actually think about what they design, they stay away from counterfeit products and they have tutorials.

Stay away from the smelly dark alleys.
Do you really think that is a MPU-6050 that you have ? It is probably counterfeit. Can you read the WHO_AM_I register ? Some older counterfeits have a different value.
The I2Cdev library is not okay. Using it with an Arduino Uno is already not nice, but using it with a ESP32 might be real trouble.
Can you forget about the MPU-6050 ? Buy a more recent sensor with a normal library.

Is this your Heltec ESP ?
They provide a schematic, that's cool 8)
I suggest however that you buy what everyone else is using (nodeMCU-alike or LOLIN).

Note to everyone: The counterfeit DS18B20 and MPU-6050 are becoming a big problem. How can we notify new users ? A message "Do not buy at Amazon, Ebay or AliExpress unless it is from a well known seller" might be a good start.

In your sketch, you have to read data from the FIFO all the time. In your sketch there is a lot going on, and the FIFO is read only now and then. If you use the FIFO, then you have to keep up with it. If you want the sensor values just now and then, then you can retrieve the sensor data without FIFO.

You are probably right about the MPU6050. There is no name of any kind on it, so I have no idea who the manufacturer. The board doe have MPU6050 printed but that is it.

That Heltec board is the one I have.

The MPU6050 does work on the sample sketch from the library. But that is interrupt driven not polled.
I tried a short sketch with GPS with the MPU in interrupt mode and it did not work well at all. It seemed like everything went crazy