Error compiling example code for MPU9250

Hi, I am trying to compile an example code for MPU9250 testing and I am getting this error:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

In file included from C:\Users\Dell\Dropbox\My PC (DESKTOP-6LMBISA)\Documents\Arduino\libraries\Bolder_Flight_Systems_MPU9250\examples\arduino\i2c\i2c.ino:26:0:

C:\Users\Dell\Dropbox\My PC (DESKTOP-6LMBISA)\Documents\Arduino\libraries\Bolder_Flight_Systems_MPU9250\src/mpu9250.h:36:10: fatal error: cstddef: No such file or directory

 #include <cstddef>

          ^~~~~~~~~

compilation terminated.

exit status 1

Error compiling for board Arduino Uno.



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

The code is provided in this link:

Code

There is line in your program

and there is no such thing in the example program. You get an error accordingly

There is line in your program the library source header "mpu9250.h"

Actually the #include is in the library, as written in the error message (and by @anon73444976)

\Documents\Arduino\libraries\Bolder_Flight_Systems_MPU9250\src/mpu9250.h

Outdated ...

You can find it here

https://github.com/bolderflight/mpu9250/blob/main/src/mpu9250.h

There seems to be a library that may solve the problem if installed

https://github.com/ddierickx/arduino/blob/master/libs/avr-stl/include/cstddef

If one googles "Arduino include cstddef" there are several threads to be found but I could not identify the reason/ background why this problem popped up... Needs some more investigation (at least one my side;-) )...

Hi @anon73444976 ,

Outdated ...

do you think including the lib I linked might solve the issue? I am not sure as I would expect that this compilation error should have appeared much more often...

I would guess that Arduino IDE installation or configuration problems could be a reason...?!?

EDIT: IDE and configuration problem seem not to be the issue. I installed Bolder Flight's mpu9250 lib and get the same error when compiling the example. Will try now what happens after installing the lib mentioned above,

EDIT: Found that some more libs from Bolder Flight are required ... Will install them and give it a try ...

EDIT: Think I found it:

TO posted:

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

Bolder Flight writes:

This library is compatible with Arduino ARM and CMake build systems.

After installing two additional libs from Bolder Flight as written on their github page

Arduino
Use the Arduino Library Manager to install this library or clone to your Arduino/libraries folder. In addition, the Bolder Flight Systems Units library and the Bolder Flight Systems Eigen library must be installed.

I was finally able to compile the i2c example, but for an ESP32 (dual core ARM processor). The libraries are designed for ARM, You tried to compile for Arduino Uno which uses an Atmega328 microcontroller.

If I am not wrong you have to change to one of the supported(!) ARM types to use this libs ...

EDIT: See also here at the github page of Bolder Flight's mpu9250 lib:

Teensy 3.x, 4.x, and LC devices are used for testing under Arduino and this library should be compatible with other Arduino ARM devices. This library is not expected to work with AVR devices.

For anything other than ESP32 I could not make the example compile (and would like to leave this to people in the forum who have experience with MKR and Due).

So you know any library to make the MPU work on uno ? Cause I can't find any...

There are several available from the IDE Library Manager. Search for MPU6050

Here is one in the reference of Arduino.cc:

https://www.arduino.cc/reference/en/libraries/mpu9250/

This library is compatible with all architectures so you should be able to use it on all the Arduino boards.

and here a link to Arduino project hub which might be quite helpful:

https://create.arduino.cc/projecthub/30503/using-the-mpu9250-to-get-real-time-motion-data-08f011

I just used the keywords "mpu9250 arduino" in Google ... :wink:

(And also quite good: https://wolles-elektronikkiste.de/en/mpu9250-9-axis-sensor-module-part-1)

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