MPU9250 library conflict with Wire.h library

When I run my code I get some weird output but the code stille compiles fine and uploads. I have lookt it up but I can't find anyone with the same problem. The code is from the mpu9250 library examples so I find it weird that I have those red errors.

#include "MPU9250.h"

MPU9250 mpu;

void setup() {
    Serial.begin(115200);
    Wire.begin();
    delay(2000);

    if (!mpu.setup(0x68)) {  // change to your own address
        while (1) {
            Serial.println("MPU connection failed. Please check your connection with `connection_check` example.");
            delay(5000);
        }
    }
}

void loop() {
    if (mpu.update()) {
        static uint32_t prev_ms = millis();
        if (millis() > prev_ms + 25) {
            print_roll_pitch_yaw();
            prev_ms = millis();
        }
    }
}

void print_roll_pitch_yaw() {
    Serial.print("Yaw, Pitch, Roll: ");
    Serial.print(mpu.getYaw(), 2);
    Serial.print(", ");
    Serial.print(mpu.getPitch(), 2);
    Serial.print(", ");
    Serial.println(mpu.getRoll(), 2);
}

The errors when compiling:

In file included from C:\Users\jorik\AppData\Local\Temp\.arduinoIDE-unsaved202424-2988-1308i6e.itvkh\simple\simple.ino:1:0:
c:\Users\jorik\OneDrive\Documenten\Arduino\libraries\MPU9250/MPU9250.h: In instantiation of 'void MPU9250_<WireType>::read_bytes(uint8_t, uint8_t, uint8_t, uint8_t*) [with WireType = TwoWire; uint8_t = unsigned char]':
c:\Users\jorik\OneDrive\Documenten\Arduino\libraries\MPU9250/MPU9250.h:428:19:   required from 'void MPU9250_<WireType>::initAK8963() [with WireType = TwoWire]'
c:\Users\jorik\OneDrive\Documenten\Arduino\libraries\MPU9250/MPU9250.h:143:27:   required from 'bool MPU9250_<WireType>::setup(uint8_t, const MPU9250Setting&, WireType&) [with WireType = TwoWire; uint8_t = unsigned char]'
C:\Users\jorik\AppData\Local\Temp\.arduinoIDE-unsaved202424-2988-1308i6e.itvkh\simple\simple.ino:11:24:   required from here
C:\Users\jorik\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:63:12: note: candidate 1: size_t TwoWire::requestFrom(int, int)
     size_t requestFrom(int, int);
            ^~~~~~~~~~~
C:\Users\jorik\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:61:12: note: candidate 2: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
     size_t requestFrom(uint8_t, size_t);
            ^~~~~~~~~~~

You did not include all of the error message, but those are probably warnings that can be ignored.

I get some weird output

Post the details of the problem you are having with the running code.

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