MPU6050_light icon indicating copy to clipboard operation
MPU6050_light copied to clipboard

Trouble using 2 mpu

Open JSlain opened this issue 2 years ago • 1 comments

I struggle to make the library working with 2 modules. At the startup of my application, sometime it's working, sometime not, or it's simply hanging.

Then i realized it seems that in the begin() function, the first time we call the update() function, preInterval = 0, and it's compared to millis() to calculate the value of dt. Depending on the order of the things you initialize in your application setup() function, the first time the millis() function will be called might give you a pretty big number, which will then enter loops in the wrap() function. The second module will be even greater, since it waits for the first ont to complete.

I noticed you initialize that variable after the update(), which is kinda weird since it's already set in the update() method itself.

  this->update();
  angleX = this->getAccAngleX();
  angleY = this->getAccAngleY();
  preInterval = millis(); // may cause lack of angular accuracy if begin() is much before the first update()
  return status;

Would it be okay to initialize the variable before update() instead of after? I'm not quite sure what it is for, but i know it's what slows me down.

JSlain avatar Jun 27 '22 22:06 JSlain

Hey, Im trying to use the setAddress() Method but im still only having the data from the 0x68 device. Can somebody help me?

Gugarauj07 avatar Jul 16 '22 20:07 Gugarauj07