Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15265

MPU9250 library conflict with Wire.h library

$
0
0

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);
            ^~~~~~~~~~~

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 15265

Trending Articles