Nicklars Posted November 12, 2016 Report Share Posted November 12, 2016 Hi, I am using NodeMCU and MPU6050 to record Accelerometer Data and send it to my PC. My Code is working fine but after about 30 seconds I get FIFO Overflow very often and then the programm crashes, I just can't figure out why. Here is my Code: // if programming failed, don't try to do anything if (!dmpReady) return; // wait for MPU interrupt or extra packet(s) available while (!mpuInterrupt && fifoCount < packetSize) { // other program behavior stuff here // . // . // . // if you are really paranoid you can frequently test in between other // stuff to see if mpuInterrupt is true, and if so, "break;" from the // while() loop to immediately process the MPU data // . // . // . } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; mpu.dmpGetAccel(&aa, fifoBuffer); tmp = String(aa.x) + " " + String(aa.y) + " " + String(aa.z) + " "; mpu.dmpGetAccel(&aa, fifoBuffer); gravityX = aa.x / 8192.0; gravityY = aa.y / 8192.0; gravityZ = aa.z / 8192.0; tmp = tmp + String(gravityX) + " " + String(gravityY) + " " + String(gravityZ) + " "; // display Euler angles in degrees mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); tmp = tmp + String(ypr[0] * 180/M_PI) + " " + String(ypr[1] * 180/M_PI) + " " + String(ypr[2] * 180/M_PI) + " "; mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity); tmp = tmp + String(aaReal.x) + " " + String(aaReal.y) + " " + String(aaReal.z) + "\r\n"; Serial.print(tmp); client.print(tmp); I know the Overflow has got something to do with the "client.print(tmp)" but I just can't figure out how to get this to work properly. Hope someone can help me, thanks, Niklas Quote Link to comment Share on other sites More sharing options...
Nicklars Posted November 13, 2016 Author Report Share Posted November 13, 2016 Ok, after doing what is described here (http://www.i2cdevlib.com/forums/topic/27-fifo-overflow/#entry99) the programm works way better, but still after about 2 minutes the program crashes, output looks like this: FIFO overflow! -6504 2399 4043 -102.56 -54.17 17.34 139 -42 -84 FIFO overflow! -6506 2389 4040 -102.56 -54.16 17.35 135 -54 -87 FIFO overflow! -6496 2389 4053 -102.54 -54.17 17.34 145 -52 -75 ... Also, I the code shows a FIFO overflow right at the beginning of the code and I dont know why. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.