Using ESP-IDF library in arduino

Im new to the ESP-IDF and platformIO and Im working on a project using an esp32 and MPU9250 over the SPI bus and im using the arduino core in Visual Studio Code. I havent found any good libraries that work over spi and the fifo of the mpu9250 except for this one: GitHub - natanaeljr/esp32-MPU-driver: ESP32 full library for all MPU6000 MPU6050 MPU6500 MPU9150 MPU9250 with SPI and I2C support and more. . As i said im totally new and have no idea how to get the library working or if its even possible.
Is anyone able to help with this?

I think you can use the library because ESP32 Arduino is based on ESP-IDF. Does it work out of the box?

Like is said in my post I’m totally new to platformIO and ESP-IDF. I only used Arduino before so I don’t even know how to install the library because there is no library folder that I can find.

All the project configuration for PlatformIO is done via the platformio.ini configuration file that’s in the root of your project folder. To install a library into your project, you want the lib_deps parameter. Since the library doesn’t appear to be in the PlatformIO Library Registry (meaning it can’t just be added by name or ID) you’ll need to add it via the GitHub path. i.e.

lib_deps = natanaeljr/esp32-MPU-driver

or

lib_deps = https://github.com/natanaeljr/esp32-MPU-driver

If you get an error because you don’t have git installed, and you don’t want to install it, you could try:

lib_deps = esp32-MPU-driver=https://github.com/natanaeljr/esp32-MPU-driver/archive/master.zip

So I got it included but I’m getting a bunch of errors when I try to build it. I’m guessing I need to setup the library some how. It says on GitHub I need to run some make file but I have no idea how. I tried running the ones in the tools folder on linux but that didn’t work.

I got it included but I’m getting errors when compiling. On the GitHub page It says I need to run a make file to set the library up. I have no idea how to run it. I’ve installed cmake but that is getting errors when I run it saying there are unknown commands and commends missing.

Well, I’ve never used this library, but it’s possible it can be used only with Espressif build tools for now: Standard Setup of Toolchain for Windows - ESP32 - — ESP-IDF Programming Guide latest documentation

Are you trying to use the library with the Arduino or the ESP-IDF framework?

In any case, ESP-IDF has its own build system (make and cmake based), which is not compatible with PlatformIO’s build system.

With the ESP-IDF build system, you can configure all parts of ESP-IDF (including all libraries) using menuconfig. It then creates a file called sdkconfig.h. However, menuconfig is not available in PlatformIO.

To configure the library, add the configuration manually in platformio.ini, something like:

build_flags =
    -D CONFIG_MPU_COMM_PROTOCOL=SPI
    -D CONFIG_MPU_SPI=1
    -D CONFIG_MPU_CHIP_MODEL=MPU9250
    -D CONFIG_MPU9250 =1
    -D CONFIG_MPU_LOG_LEVEL=3
    -D CONFIG_MPU_ENABLE_DMP=n
    -D CONFIG_MPU_LOG_ERROR_TRACES=y

I’m not sure the ESP-IDF structure for a library is a fit for PlatformIO. If you run into problems, you can also try to put the library files into the project’s lib directory such that it fits the structure expected by PlatformIO (see README and further PlatformIO documentation).

If you try to use the library with the Arduino framework, then further modifications are needed…

Yes I’m trying to get it working for the Arduino framework. Would it need a lot of modifications or is it something simpler? This is a pretty big project so I’m willing to rewrite quite a big of the library. I just don’t quite understand how big of a difference it makes if the library is made for the ESP-IDF framework or the Arduino framework.