B4R Library rMPU9250 library

this is library for MPU9250, based on MPU9250_asukiaaa : https://github.com/asukiaaa/MPU9250_asukiaaa

with this library, you can read Accelerometer, Gyrometer and Magnetometer of MPU9250.

this library can work on wire, wire1 and wire2, based on HardWire or SoftwareWire

parameters for configuration are available on B4R interface.

a small B4R project is added, it was used to test this library.
For tests, i bought 2 MPU9250 on Aliexpress and on first one Gyro was not answering , on second one Magnetometer was not working.
=> on Aliexpress this module is cheap but not fiable, i saw a lot of peoples complaining
 

Attachments

  • rMPU9250.zip
    16.8 KB · Views: 56

Chris Tyrie

Member
Licensed User
I'm trying to compile this library for a MEGA using B4R 3.71 and I'm getting...

C:\Users\Acer\DOCUME~1\B4RPRO~1\MPU9250\Objects\src\rMPU9250.cpp: In member function 'void B4R::B4RMPU9250_asukiaaa::Initialize2(byte, byte, byte, byte)':
rMPU9250.cpp:17:59: error: no matching function for call to 'TwoWire::begin(byte&, byte&)'
if (I2Cbus==2) {TwoWire Wire2; Wire2.begin(sda, scl); rcs->setWire(&Wire2);};
^
In file included from C:\Users\Acer\DOCUME~1\B4RPRO~1\MPU9250\Objects\src\B4RDefines.h:22:0,
from C:\Users\Acer\DOCUME~1\B4RPRO~1\MPU9250\Objects\src\rMPU9250.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:53:10: note: candidate: void TwoWire::begin()
void begin();
^~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:53:10: note: candidate expects 0 arguments, 2 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:54:10: note: candidate: void TwoWire::begin(uint8_t)
void begin(uint8_t);
^~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:54:10: note: candidate expects 1 argument, 2 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:55:10: note: candidate: void TwoWire::begin(int)
void begin(int);
^~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:55:10: note: candidate expects 1 argument, 2 provided
rMPU9250.cpp:18:59: error: no matching function for call to 'TwoWire::begin(byte&, byte&)'
if (I2Cbus==1) {TwoWire Wire1; Wire1.begin(sda, scl); rcs->setWire(&Wire1);}
^
In file included from C:\Users\Acer\DOCUME~1\B4RPRO~1\MPU9250\Objects\src\B4RDefines.h:22:0,
from C:\Users\Acer\DOCUME~1\B4RPRO~1\MPU9250\Objects\src\rMPU9250.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:53:10: note: candidate: void TwoWire::begin()
void begin();
^~~~~


Surely my Wire library it's behind. This isn't an ESP only library or something, is it?
 

candide

Active Member
Licensed User
yes it was tested only with esp8266.

i will check in Mega configuration
after a check, wrapper with 2 initialize phases, one for ESP and one for Arduino is not working for MEGA because compilation is done for both phases and "initialize2" is not compatible with MEGA

a quick solution is to modify "rMPU9250.cpp" in this way:
void B4RMPU9250_asukiaaa::Initialize2(byte I2Cbus,byte sda, byte scl, byte MPU9250_ADDR)
{
rcs = new (backend) MPU9250_asukiaaa(MPU9250_ADDR);
// if (I2Cbus==2) {TwoWire Wire2; Wire2.begin(sda, scl); rcs->setWire(&Wire2);};
// if (I2Cbus==1) {TwoWire Wire1; Wire1.begin(sda, scl); rcs->setWire(&Wire1);}
// else {Wire.begin(sda, scl); rcs->setWire(&Wire);};
// Wire.begin(sda, scl); rcs->setWire(&Wire);
};

i will try to modify this wrapper to be compatible for esp and MEGA in a few days
 
Top