Trouble with Dual MPU9250 Library

Hello,
I am currently working on a head-movement wheelchair project and plan on using 2 MPU9250 to calculate the yaw difference and turn a motor to compensate for the difference when the "head" moves. I'm quite new to Arduino so pardon my inexperience.

I am facing a couple of problems trying to import the files (GitHub - kriswiner/MPU9250: Arduino sketches for MPU9250 9DoF with AHRS sensor fusion) as a library. The error message "Specified folder/zip file does not contain a valid library" pops up when I try using the Arduino's built-in library manager. Thus, I tried installing it manually, but no examples came up after I extracted the files so I tried making an example folder by moving the "Dual_MPU9250" file in it and moving all other files out, which worked but led to problems when compiling. I would assume that I did the manual installation wrongly and I hope someone can help me out. Thank you.

This is the error message I'm getting. Namely a conflicting declaration of the variable A12.

Arduino: 1.8.13 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Dual_MPU9250_dual_Ladybug:85:7: error: conflicting declaration 'float A12'

float A12, A22, A31, A32, A33; // rotation matrix coefficients for Euler angles and gravity components

^~~

In file included from D:\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:258:0,

from sketch\Dual_MPU9250_dual_Ladybug.ino.cpp:1:

D:\Arduino\hardware\arduino\avr\variants\mega/pins_arduino.h:80:22: note: previous declaration as 'const uint8_t A12'

static const uint8_t A12 = PIN_A12;

^~~

C:\Users\Bao\Downloads\MPU9250Lib\MPU9250-master\Dual_MPU9250\Dual_MPU9250_dual_Ladybug\Dual_MPU9250_dual_Ladybug.ino: In function 'void setup()':

Dual_MPU9250_dual_Ladybug:199:28: error: 'myinthandler1' was not declared in this scope

attachInterrupt(intPin1, myinthandler1, RISING); // define interrupt for intPin output of MPU9250 1

^~~~~~~~~~~~~

Dual_MPU9250_dual_Ladybug:200:28: error: 'myinthandler2' was not declared in this scope

attachInterrupt(intPin2, myinthandler2, RISING); // define interrupt for intPin output of MPU9250 2

^~~~~~~~~~~~~

C:\Users\Bao\Downloads\MPU9250Lib\MPU9250-master\Dual_MPU9250\Dual_MPU9250_dual_Ladybug\Dual_MPU9250_dual_Ladybug.ino: In function 'void loop()':

Dual_MPU9250_dual_Ladybug:271:5: error: 'MadgwickQuaternionUpdate1' was not declared in this scope

MadgwickQuaternionUpdate1(-ax1, +ay1, +az1, gx1pi/180.0f, -gy1pi/180.0f, -gz1*pi/180.0f, my1, -mx1, mz1);

^~~~~~~~~~~~~~~~~~~~~~~~~

Dual_MPU9250_dual_Ladybug:316:5: error: 'MadgwickQuaternionUpdate2' was not declared in this scope

MadgwickQuaternionUpdate2(-ax2, +ay2, +az2, gx2pi/180.0f, -gy2pi/180.0f, -gz2*pi/180.0f, my2, -mx2, mz2);

^~~~~~~~~~~~~~~~~~~~~~~~~

Dual_MPU9250_dual_Ladybug:428:46: error: assignment of read-only variable 'A12'

A12 = 2.0f * (Q[1] * Q[2] + Q[0] * Q[3]);

^

C:\Users\Bao\Downloads\MPU9250Lib\MPU9250-master\Dual_MPU9250\Dual_MPU9250_dual_Ladybug\Dual_MPU9250_dual_Ladybug.ino: At global scope:

Dual_MPU9250_dual_Ladybug:481:1: error: expected declaration before '}' token

}

^

exit status 1

conflicting declaration 'float A12'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

That is not a library. It is a sketch. If you unzip the entire repo, you need to create a directory in your sketch folder called
'Dual_MPU9250_dual_Ladybug' and then put all those files in that folder: Dual_MPU9250_dual_Ladybug.ino, MPU9250.cpp, MPU9250.h and then just open the .ino file (or double click on it)

The Arduino IDE demands that the sketch filename match the directory that contains it.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.